@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;
@@ -648,6 +1032,18 @@ function setModule(module2) {
648
1032
  }
649
1033
  __name(setModule, "setModule");
650
1034
  var C;
1035
+ function newFinalizer(handler) {
1036
+ try {
1037
+ return new FinalizationRegistry(handler);
1038
+ } catch (e) {
1039
+ console.error("Unsupported FinalizationRegistry:", e);
1040
+ return;
1041
+ }
1042
+ }
1043
+ __name(newFinalizer, "newFinalizer");
1044
+ var finalizer = newFinalizer((address) => {
1045
+ C._ts_lookahead_iterator_delete(address);
1046
+ });
651
1047
  var LookaheadIterator = class {
652
1048
  static {
653
1049
  __name(this, "LookaheadIterator");
@@ -658,21 +1054,39 @@ var LookaheadIterator = class {
658
1054
  /** @internal */
659
1055
  language;
660
1056
  /** @internal */
1057
+ positioned = false;
1058
+ /** @internal */
661
1059
  constructor(internal, address, language) {
662
1060
  assertInternal(internal);
663
1061
  this[0] = address;
664
1062
  this.language = language;
1063
+ finalizer?.register(this, address, this);
665
1064
  }
666
- /** Get the current symbol of the lookahead iterator. */
1065
+ /**
1066
+ * Get the current symbol of the lookahead iterator.
1067
+ *
1068
+ * Returns `null` if the iterator is not positioned on a symbol:
1069
+ *
1070
+ * - Before the first iteration step
1071
+ * - After the iterator is exhausted
1072
+ * - After a {@link reset} or {@link resetState} call
1073
+ */
667
1074
  get currentTypeId() {
668
- return C._ts_lookahead_iterator_current_symbol(this[0]);
1075
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
669
1076
  }
670
- /** Get the current symbol name of the lookahead iterator. */
1077
+ /**
1078
+ * Get the current symbol name of the lookahead iterator.
1079
+ *
1080
+ * Returns `null` if the iterator is not positioned on a symbol.
1081
+ */
671
1082
  get currentType() {
672
- return this.language.types[this.currentTypeId] || "ERROR";
1083
+ const id = this.currentTypeId;
1084
+ if (id === null) return null;
1085
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
673
1086
  }
674
1087
  /** Delete the lookahead iterator, freeing its resources. */
675
1088
  delete() {
1089
+ finalizer?.unregister(this);
676
1090
  C._ts_lookahead_iterator_delete(this[0]);
677
1091
  this[0] = 0;
678
1092
  }
@@ -685,6 +1099,7 @@ var LookaheadIterator = class {
685
1099
  reset(language, stateId) {
686
1100
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
687
1101
  this.language = language;
1102
+ this.positioned = false;
688
1103
  return true;
689
1104
  }
690
1105
  return false;
@@ -696,7 +1111,9 @@ var LookaheadIterator = class {
696
1111
  * `false` otherwise.
697
1112
  */
698
1113
  resetState(stateId) {
699
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
1114
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
1115
+ this.positioned = false;
1116
+ return true;
700
1117
  }
701
1118
  /**
702
1119
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -707,10 +1124,9 @@ var LookaheadIterator = class {
707
1124
  [Symbol.iterator]() {
708
1125
  return {
709
1126
  next: /* @__PURE__ */ __name(() => {
710
- if (C._ts_lookahead_iterator_next(this[0])) {
711
- return { done: false, value: this.currentType };
712
- }
713
- return { done: true, value: "" };
1127
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
1128
+ const value = this.currentType;
1129
+ return value === null ? { done: true, value: "" } : { done: false, value };
714
1130
  }, "next")
715
1131
  };
716
1132
  }
@@ -736,6 +1152,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
736
1152
  return result ?? "";
737
1153
  }
738
1154
  __name(getText, "getText");
1155
+ var finalizer2 = newFinalizer((address) => {
1156
+ C._ts_tree_delete(address);
1157
+ });
739
1158
  var Tree = class _Tree {
740
1159
  static {
741
1160
  __name(this, "Tree");
@@ -753,6 +1172,7 @@ var Tree = class _Tree {
753
1172
  this[0] = address;
754
1173
  this.language = language;
755
1174
  this.textCallback = textCallback;
1175
+ finalizer2?.register(this, address, this);
756
1176
  }
757
1177
  /** Create a shallow copy of the syntax tree. This is very fast. */
758
1178
  copy() {
@@ -761,6 +1181,7 @@ var Tree = class _Tree {
761
1181
  }
762
1182
  /** Delete the syntax tree, freeing its resources. */
763
1183
  delete() {
1184
+ finalizer2?.unregister(this);
764
1185
  C._ts_tree_delete(this[0]);
765
1186
  this[0] = 0;
766
1187
  }
@@ -841,6 +1262,9 @@ var Tree = class _Tree {
841
1262
  return result;
842
1263
  }
843
1264
  };
1265
+ var finalizer3 = newFinalizer((address) => {
1266
+ C._ts_tree_cursor_delete_wasm(address);
1267
+ });
844
1268
  var TreeCursor = class _TreeCursor {
845
1269
  static {
846
1270
  __name(this, "TreeCursor");
@@ -868,6 +1292,7 @@ var TreeCursor = class _TreeCursor {
868
1292
  assertInternal(internal);
869
1293
  this.tree = tree;
870
1294
  unmarshalTreeCursor(this);
1295
+ finalizer3?.register(this, this.tree[0], this);
871
1296
  }
872
1297
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
873
1298
  copy() {
@@ -878,6 +1303,7 @@ var TreeCursor = class _TreeCursor {
878
1303
  }
879
1304
  /** Delete the tree cursor, freeing its resources. */
880
1305
  delete() {
1306
+ finalizer3?.unregister(this);
881
1307
  marshalTreeCursor(this);
882
1308
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
883
1309
  this[0] = this[1] = this[2] = 0;
@@ -1972,8 +2398,9 @@ var Language = class _Language {
1972
2398
  * This returns `null` if state is invalid for this language.
1973
2399
  *
1974
2400
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
1975
- * parse state. Newly created lookahead iterators will return the `ERROR`
1976
- * symbol from {@link LookaheadIterator#currentType}.
2401
+ * parse state. A newly created iterator is not positioned on a symbol, so
2402
+ * {@link LookaheadIterator#currentType} returns `null` until the first
2403
+ * iteration step.
1977
2404
  *
1978
2405
  * Lookahead iterators can be useful for generating suggestions and improving
1979
2406
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -1988,7 +2415,8 @@ var Language = class _Language {
1988
2415
  }
1989
2416
  /**
1990
2417
  * Load a language from a WebAssembly module.
1991
- * The module can be provided as a path to a file or as a buffer.
2418
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
2419
+ * buffer.
1992
2420
  */
1993
2421
  static async load(input) {
1994
2422
  let binary2;
@@ -2015,16 +2443,27 @@ ${body2}`);
2015
2443
  }
2016
2444
  }
2017
2445
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
2446
+ return _Language.loadFromWasmExports(mod, { sync: false });
2447
+ }
2448
+ static loadFromWasmExports(mod, { sync }) {
2018
2449
  const symbolNames = Object.keys(mod);
2019
2450
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2020
2451
  if (!functionName) {
2021
2452
  console.log(`Couldn't find language function in Wasm file. Symbols:
2022
2453
  ${JSON.stringify(symbolNames, null, 2)}`);
2023
- throw new Error("Language.load failed: no language function found in Wasm file");
2454
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
2024
2455
  }
2025
2456
  const languageAddress = mod[functionName]();
2026
2457
  return new _Language(INTERNAL, languageAddress);
2027
2458
  }
2459
+ /**
2460
+ * Load a language synchronously from a pre-compiled WebAssembly module.
2461
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
2462
+ */
2463
+ static loadSync(wasmModule) {
2464
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
2465
+ return _Language.loadFromWasmExports(mod, { sync: true });
2466
+ }
2028
2467
  };
2029
2468
  async function Module2(moduleArg = {}) {
2030
2469
  var moduleRtn;
@@ -2547,7 +2986,7 @@ async function Module2(moduleArg = {}) {
2547
2986
  newDSO("__main__", 0, wasmImports);
2548
2987
  }
2549
2988
  };
2550
- var ___heap_base = 78240;
2989
+ var ___heap_base = 82240;
2551
2990
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2552
2991
  var getMemory = /* @__PURE__ */ __name((size) => {
2553
2992
  if (runtimeInitialized) {
@@ -3112,12 +3551,12 @@ async function Module2(moduleArg = {}) {
3112
3551
  "value": "i32",
3113
3552
  "mutable": false
3114
3553
  }, 1024);
3115
- var ___stack_high = 78240;
3116
- var ___stack_low = 12704;
3554
+ var ___stack_high = 82240;
3555
+ var ___stack_low = 16704;
3117
3556
  var ___stack_pointer = new WebAssembly.Global({
3118
3557
  "value": "i32",
3119
3558
  "mutable": true
3120
- }, 78240);
3559
+ }, 82240);
3121
3560
  var ___table_base = new WebAssembly.Global({
3122
3561
  "value": "i32",
3123
3562
  "mutable": false
@@ -3378,7 +3817,7 @@ async function Module2(moduleArg = {}) {
3378
3817
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3379
3818
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
3380
3819
  var ASM_CONSTS = {};
3381
- 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;
3820
+ 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;
3382
3821
  function assignWasmExports(wasmExports2) {
3383
3822
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
3384
3823
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -3412,6 +3851,7 @@ async function Module2(moduleArg = {}) {
3412
3851
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
3413
3852
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
3414
3853
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
3854
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
3415
3855
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
3416
3856
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
3417
3857
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -3517,6 +3957,7 @@ async function Module2(moduleArg = {}) {
3517
3957
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
3518
3958
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
3519
3959
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
3960
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
3520
3961
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
3521
3962
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
3522
3963
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -3654,6 +4095,10 @@ __name(checkModule, "checkModule");
3654
4095
  var TRANSFER_BUFFER;
3655
4096
  var LANGUAGE_VERSION;
3656
4097
  var MIN_COMPATIBLE_VERSION;
4098
+ var finalizer4 = newFinalizer((addresses) => {
4099
+ C._ts_parser_delete(addresses[0]);
4100
+ C._free(addresses[1]);
4101
+ });
3657
4102
  var Parser = class {
3658
4103
  static {
3659
4104
  __name(this, "Parser");
@@ -3685,6 +4130,7 @@ var Parser = class {
3685
4130
  */
3686
4131
  constructor() {
3687
4132
  this.initialize();
4133
+ finalizer4?.register(this, [this[0], this[1]], this);
3688
4134
  }
3689
4135
  /** @internal */
3690
4136
  initialize() {
@@ -3697,6 +4143,7 @@ var Parser = class {
3697
4143
  }
3698
4144
  /** Delete the parser, freeing its resources. */
3699
4145
  delete() {
4146
+ finalizer4?.unregister(this);
3700
4147
  C._ts_parser_delete(this[0]);
3701
4148
  C._free(this[1]);
3702
4149
  this[0] = 0;
@@ -3872,6 +4319,10 @@ var QueryError = class _QueryError extends Error {
3872
4319
  this.length = length;
3873
4320
  this.name = "QueryError";
3874
4321
  }
4322
+ kind;
4323
+ info;
4324
+ index;
4325
+ length;
3875
4326
  static {
3876
4327
  __name(this, "QueryError");
3877
4328
  }
@@ -4067,6 +4518,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
4067
4518
  }
4068
4519
  }
4069
4520
  __name(parsePattern, "parsePattern");
4521
+ var finalizer5 = newFinalizer((address) => {
4522
+ C._ts_query_delete(address);
4523
+ });
4070
4524
  var Query = class {
4071
4525
  static {
4072
4526
  __name(this, "Query");
@@ -4221,9 +4675,11 @@ var Query = class {
4221
4675
  this.assertedProperties = assertedProperties;
4222
4676
  this.refutedProperties = refutedProperties;
4223
4677
  this.exceededMatchLimit = false;
4678
+ finalizer5?.register(this, address, this);
4224
4679
  }
4225
4680
  /** Delete the query, freeing its resources. */
4226
4681
  delete() {
4682
+ finalizer5?.unregister(this);
4227
4683
  C._ts_query_delete(this[0]);
4228
4684
  this[0] = 0;
4229
4685
  }