@mnemonik/cli 7.114.1 → 7.114.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -39,13 +39,15 @@ var require_ignore = __commonJS({
39
39
  var EMPTY = "";
40
40
  var SPACE = " ";
41
41
  var ESCAPE = "\\";
42
- var REGEX_TEST_BLANK_LINE = /^\s+$/;
42
+ var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
43
+ var BOM = "\uFEFF";
43
44
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
44
45
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
45
46
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
46
47
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
47
- var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
48
- var REGEX_TEST_TRAILING_SLASH = /\/$/;
48
+ var DOUBLE_SLASH = "//";
49
+ var SLASH_CODE = 47;
50
+ var DOT_CODE = 46;
49
51
  var SLASH = "/";
50
52
  var TMP_KEY_IGNORE = "node-ignore";
51
53
  if (typeof Symbol !== "undefined") {
@@ -56,44 +58,173 @@ var require_ignore = __commonJS({
56
58
  Object.defineProperty(object, key, { value });
57
59
  return value;
58
60
  };
59
- var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
60
61
  var RETURN_FALSE = () => false;
61
- var sanitizeRange = (range) => range.replace(
62
- REGEX_REGEXP_RANGE,
63
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
64
- );
65
- var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
66
62
  var cleanRangeBackSlash = (slashes) => {
67
63
  const { length } = slashes;
68
64
  return slashes.slice(0, length - length % 2);
69
65
  };
66
+ var POSIX_CLASSES = {
67
+ alnum: "0-9A-Za-z",
68
+ alpha: "A-Za-z",
69
+ blank: " \\t",
70
+ cntrl: "\\x00-\\x1f\\x7f",
71
+ digit: "0-9",
72
+ graph: "!-.0-~",
73
+ lower: "a-z",
74
+ print: " -.0-~",
75
+ punct: "!-.:-@\\[-`{-~",
76
+ // git's `sane-ctype.h` classifies \v and \f as control, not space,
77
+ // unlike C's `isspace`
78
+ space: " \\t\\n\\r",
79
+ upper: "A-Z",
80
+ xdigit: "0-9A-Fa-f"
81
+ };
82
+ var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
83
+ var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
84
+ var NON_SLASH = "(?!\\/)";
85
+ var classSource = (negated, body2) => {
86
+ if (negated) {
87
+ return `[^\\/${body2}]`;
88
+ }
89
+ const source = `[${body2}]`;
90
+ return new RegExp(source).test("/") ? NON_SLASH + source : source;
91
+ };
92
+ var scanBracket = (pattern, start2) => {
93
+ const { length } = pattern;
94
+ let index = start2 + 1;
95
+ let negated = EMPTY;
96
+ const lead = pattern[index];
97
+ if (lead === "!" || lead === "^") {
98
+ negated = "^";
99
+ index++;
100
+ }
101
+ let body2 = EMPTY;
102
+ let prev = EMPTY;
103
+ for (; ; ) {
104
+ const char = pattern[index];
105
+ if (char === UNDEFINED) {
106
+ return null;
107
+ }
108
+ if (char === ESCAPE) {
109
+ const escaped = pattern[index + 1];
110
+ if (escaped === UNDEFINED) {
111
+ return null;
112
+ }
113
+ body2 += escapeMember(escaped);
114
+ prev = escaped;
115
+ index++;
116
+ } else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
117
+ index++;
118
+ let to = pattern[index];
119
+ if (to === ESCAPE) {
120
+ to = pattern[index += 1];
121
+ }
122
+ if (prev <= to) {
123
+ body2 += `-${escapeMember(to)}`;
124
+ }
125
+ prev = EMPTY;
126
+ } else if (char === "[" && pattern[index + 1] === ":") {
127
+ const nameStart = index + 2;
128
+ let end = nameStart;
129
+ while (end < length && pattern[end] !== "]") {
130
+ end++;
131
+ }
132
+ if (end === length) {
133
+ return null;
134
+ }
135
+ if (end > nameStart && pattern[end - 1] === ":") {
136
+ const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
137
+ if (expanded === UNDEFINED) {
138
+ return null;
139
+ }
140
+ body2 += expanded;
141
+ prev = EMPTY;
142
+ index = end;
143
+ } else {
144
+ body2 += escapeMember("[");
145
+ prev = "[";
146
+ index = nameStart - 2;
147
+ }
148
+ } else {
149
+ body2 += escapeMember(char);
150
+ prev = char;
151
+ }
152
+ index++;
153
+ if (pattern[index] === "]") {
154
+ return {
155
+ end: index,
156
+ source: classSource(negated, body2)
157
+ };
158
+ }
159
+ }
160
+ };
161
+ var NEVER_MATCH = "[]";
162
+ var PLACEHOLDER = "\0";
163
+ var REGEX_RESTORE_PLACEHOLDER = new RegExp(
164
+ `${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
165
+ "g"
166
+ );
167
+ var TRAILING_WILDCARD = "\uE000";
168
+ var TRAILING_DOUBLESTAR = "\uE001";
169
+ var extractBrackets = (pattern) => {
170
+ const sources = [];
171
+ const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
172
+ const { length } = pattern;
173
+ let out2 = EMPTY;
174
+ let index = 0;
175
+ while (index < length) {
176
+ const char = pattern[index];
177
+ if (char === ESCAPE) {
178
+ const escaped = pattern[index + 1];
179
+ if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
180
+ out2 += hold(NEVER_MATCH);
181
+ } else if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
182
+ out2 += pattern.slice(index, index + 2);
183
+ } else {
184
+ out2 += hold(
185
+ REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
186
+ );
187
+ }
188
+ index += 2;
189
+ } else if (char === PLACEHOLDER) {
190
+ out2 += hold(`[${PLACEHOLDER}]`);
191
+ index++;
192
+ } else if (char === "[") {
193
+ const scanned = scanBracket(pattern, index);
194
+ if (scanned === null) {
195
+ out2 += hold(NEVER_MATCH);
196
+ index = length;
197
+ } else {
198
+ out2 += hold(scanned.source);
199
+ index = scanned.end + 1;
200
+ }
201
+ } else {
202
+ out2 += char;
203
+ index++;
204
+ }
205
+ }
206
+ return {
207
+ source: out2,
208
+ sources
209
+ };
210
+ };
211
+ var DIRECT = null;
212
+ var REGEX_INNER_SLASH = /\/(?!$)/;
70
213
  var REPLACERS = [
71
- [
72
- // Remove BOM
73
- // TODO:
74
- // Other similar zero-width characters?
75
- /^\uFEFF/,
76
- () => EMPTY
77
- ],
78
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
79
- [
80
- // (a\ ) -> (a )
81
- // (a ) -> (a)
82
- // (a ) -> (a)
83
- // (a \ ) -> (a )
84
- /((?:\\\\)*?)(\\?\s+)$/,
85
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
86
- ],
87
214
  // Replace (\ ) with ' '
215
+ // Only a space: an escaped tab or other whitespace is already a literal by
216
+ // the time it reaches here, and a bare tab must be left as one, not turned
217
+ // into a space.
88
218
  // (\ ) -> ' '
89
219
  // (\\ ) -> '\\ '
90
220
  // (\\\ ) -> '\\ '
91
221
  [
92
- /(\\+?)\s/g,
93
- (_, m1) => {
94
- const { length } = m1;
95
- return m1.slice(0, length - length % 2) + SPACE;
96
- }
222
+ // A run of backslashes is taken whole, from its first one, so no match
223
+ // ever starts again inside it -- `(\\+?) ` did, which made a long run
224
+ // quadratic.
225
+ /(\\+)( ?)/g,
226
+ (_, run2, space) => space ? run2.slice(0, run2.length - run2.length % 2) + SPACE : run2,
227
+ ESCAPE + SPACE
97
228
  ],
98
229
  // Escape metacharacters
99
230
  // which is written down by users but means special for regular expressions.
@@ -118,7 +249,8 @@ var require_ignore = __commonJS({
118
249
  [
119
250
  // > a question mark (?) matches a single character
120
251
  /(?!\\)\?/g,
121
- () => "[^/]"
252
+ () => "[^/]",
253
+ "?"
122
254
  ],
123
255
  // leading slash
124
256
  [
@@ -126,12 +258,14 @@ var require_ignore = __commonJS({
126
258
  // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
127
259
  // A leading slash matches the beginning of the pathname
128
260
  /^\//,
129
- () => "^"
261
+ () => "^",
262
+ SLASH
130
263
  ],
131
264
  // replace special metacharacter slash after the leading slash
132
265
  [
133
266
  /\//g,
134
- () => "\\/"
267
+ () => "\\/",
268
+ SLASH
135
269
  ],
136
270
  [
137
271
  // > A leading "**" followed by a slash means match in all directories.
@@ -142,16 +276,21 @@ var require_ignore = __commonJS({
142
276
  // Notice that the '*'s have been replaced as '\\*'
143
277
  /^\^*(?:\\\*\\\*\\\/)+/,
144
278
  // '**/foo' <-> 'foo'
145
- () => "^(?:.*\\/)?"
279
+ () => "^(?:.*\\/)?",
280
+ "*"
146
281
  ],
147
282
  // starting
148
283
  [
149
284
  // there will be no leading '/'
150
285
  // (which has been replaced by section "leading slash")
151
286
  // If starts with '**', adding a '^' to the regular expression also works
152
- /^(?=[^^])/,
153
- function startingReplacer() {
154
- return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
287
+ DIRECT,
288
+ (source, pattern) => {
289
+ if (!source || source[0] === "^") {
290
+ return source;
291
+ }
292
+ const anchor = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
293
+ return anchor + source;
155
294
  }
156
295
  ],
157
296
  // two globstars
@@ -161,7 +300,8 @@ var require_ignore = __commonJS({
161
300
  // Zero, one or several directories
162
301
  // should not use '*', or it will be replaced by the next replacer
163
302
  // Check if it is not the last `'/**'`
164
- (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
303
+ (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
304
+ "*"
165
305
  ],
166
306
  // normal intermediate wildcards
167
307
  [
@@ -176,32 +316,56 @@ var require_ignore = __commonJS({
176
316
  (_, p1, p2) => {
177
317
  const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
178
318
  return p1 + unescaped;
179
- }
319
+ },
320
+ "*"
321
+ ],
322
+ // trailing wildcard, held apart from a literal star
323
+ [
324
+ // The step above leaves a trailing `*` alone, so a single `\*` is all that
325
+ // can be left at the end here. Whether it is a wildcard or a literal
326
+ // turns on the backslashes the user put in front of it: the escaper has
327
+ // since doubled every one, so what stands here is those `2N` doubled
328
+ // backslashes and then the star's own escape. An even number of the
329
+ // original `N` leaves the star unescaped -- a wildcard -- and an odd
330
+ // number escapes it -- a literal. This runs while the two are still
331
+ // distinct, before the unescape steps below collapse the literal onto
332
+ // the very `\*` a wildcard leaves behind.
333
+ /(^|[^\\])((?:\\\\)*)\\\*$/,
334
+ (match, p1, p2) => (
335
+ // `p2` holds the doubled user backslashes; half of them is `N`.
336
+ p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
337
+ ),
338
+ "*"
180
339
  ],
181
340
  [
182
341
  // unescape, revert step 3 except for back slash
183
342
  // For example, if a user escape a '\\*',
184
343
  // after step 3, the result will be '\\\\\\*'
185
344
  /\\\\\\(?=[$.|*+(){^])/g,
186
- () => ESCAPE
345
+ () => ESCAPE,
346
+ ESCAPE + ESCAPE
187
347
  ],
188
348
  [
189
349
  // '\\\\' -> '\\'
190
350
  /\\\\/g,
191
- () => ESCAPE
351
+ () => ESCAPE,
352
+ ESCAPE + ESCAPE
192
353
  ],
193
354
  [
194
- // > The range notation, e.g. [a-zA-Z],
195
- // > can be used to match one of the characters in a range.
355
+ // Every real bracket expression -- POSIX classes included -- has already
356
+ // been held aside by `extractBrackets`, so the only `[` left in the
357
+ // pattern is an escaped, literal one.
196
358
  // `\` is escaped by step 3
197
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
198
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
359
+ /\\\[([^\]/]*?)(\\*)($|\])/g,
360
+ // '\\[bar]' -> '\\\\[bar\\]'
361
+ (match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
362
+ "["
199
363
  ],
200
364
  // ending
201
365
  [
202
366
  // 'js' will not match 'js.'
203
367
  // 'ab' will not match 'abc'
204
- /(?:[^*])$/,
368
+ DIRECT,
205
369
  // WTF!
206
370
  // https://git-scm.com/docs/gitignore
207
371
  // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
@@ -212,29 +376,175 @@ var require_ignore = __commonJS({
212
376
  // 'js*' will not match 'a.js'
213
377
  // 'js/' will not match 'a.js'
214
378
  // 'js' will match 'a.js' and 'a.js/'
215
- (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
379
+ (source) => {
380
+ const last = source[source.length - 1];
381
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
382
+ return source;
383
+ }
384
+ return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
385
+ }
216
386
  ]
217
387
  ];
218
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
388
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
219
389
  var MODE_IGNORE = "regex";
220
390
  var MODE_CHECK_IGNORE = "checkRegex";
221
391
  var UNDERSCORE = "_";
222
- var TRAILING_WILD_CARD_REPLACERS = {
223
- [MODE_IGNORE](_, p1) {
224
- const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
225
- return `${prefix}(?=$|\\/$)`;
226
- },
227
- [MODE_CHECK_IGNORE](_, p1) {
228
- const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
229
- return `${prefix}(?=$|\\/$)`;
392
+ var replaceTrailingWildcard = (_, p1) => {
393
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
394
+ return `${prefix}(?=$|\\/$)`;
395
+ };
396
+ var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
397
+ var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
398
+ var WILDCARD = "[^\\/]*";
399
+ var separatorAfter = (run2, at) => {
400
+ let separator = EMPTY;
401
+ for (let index = at + 1; index < run2.length && !run2[index].wildcard; index++) {
402
+ separator += run2[index].single;
230
403
  }
404
+ return separator;
405
+ };
406
+ var pinWildcards = (source) => {
407
+ if (source.indexOf(WILDCARD) < 0) {
408
+ return source;
409
+ }
410
+ const tokens = [];
411
+ const { length } = source;
412
+ let index = 0;
413
+ while (index < length) {
414
+ const char = source[index];
415
+ if (source.startsWith(WILDCARD, index)) {
416
+ tokens.push({ wildcard: true });
417
+ index += WILDCARD.length;
418
+ } else if (char === "[") {
419
+ let end = index + 1;
420
+ if (source[end] === "^") {
421
+ end++;
422
+ }
423
+ if (source[end] === "]") {
424
+ end++;
425
+ }
426
+ while (end < length && source[end] !== "]") {
427
+ end += source[end] === ESCAPE ? 2 : 1;
428
+ }
429
+ end++;
430
+ tokens.push({ single: source.slice(index, end) });
431
+ index = end;
432
+ } else if (char === ESCAPE) {
433
+ tokens.push({ single: source.slice(index, index + 2) });
434
+ index += 2;
435
+ } else if (char === "(") {
436
+ let depth = 0;
437
+ let end = index;
438
+ do {
439
+ if (source[end] === ESCAPE) {
440
+ end++;
441
+ } else if (source[end] === "(") {
442
+ depth++;
443
+ } else if (source[end] === ")") {
444
+ depth--;
445
+ }
446
+ end++;
447
+ } while (end < length && depth > 0);
448
+ if ("*+?".indexOf(source[end]) >= 0) {
449
+ end++;
450
+ }
451
+ tokens.push({ boundary: source.slice(index, end) });
452
+ index = end;
453
+ } else if (char === "^" || char === "$") {
454
+ tokens.push({ boundary: char });
455
+ index++;
456
+ } else {
457
+ tokens.push({ single: char });
458
+ index++;
459
+ }
460
+ }
461
+ let out2 = EMPTY;
462
+ let run2 = [];
463
+ const flush = () => {
464
+ let lastWildcard;
465
+ run2.forEach((token, at) => {
466
+ if (token.wildcard) {
467
+ lastWildcard = at;
468
+ }
469
+ });
470
+ run2.forEach((token, at) => {
471
+ if (!token.wildcard) {
472
+ out2 += token.single;
473
+ return;
474
+ }
475
+ out2 += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run2, at)})[^\\/])*`;
476
+ });
477
+ run2 = [];
478
+ };
479
+ tokens.forEach((token) => {
480
+ if (token.boundary === void 0) {
481
+ run2.push(token);
482
+ return;
483
+ }
484
+ flush();
485
+ out2 += token.boundary;
486
+ });
487
+ flush();
488
+ return out2;
489
+ };
490
+ var makeRegexPrefix = (pattern) => {
491
+ const { source, sources } = extractBrackets(pattern);
492
+ const replaced = REPLACERS.reduce(
493
+ // A pass whose matcher finds nothing hands back the very string it was
494
+ // given, so asking first costs a search and saves a rewrite. Ten of the
495
+ // fifteen passes never fire for a typical .gitignore line, and between
496
+ // them they were 45% of this chain.
497
+ (prev, [matcher, replacer, required]) => {
498
+ if (matcher === DIRECT) {
499
+ return replacer(prev, pattern);
500
+ }
501
+ if (required !== UNDEFINED && prev.indexOf(required) < 0) {
502
+ return prev;
503
+ }
504
+ return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
505
+ },
506
+ source
507
+ );
508
+ return sources.length ? replaced.replace(
509
+ REGEX_RESTORE_PLACEHOLDER,
510
+ (match, index) => sources[index]
511
+ ) : replaced;
512
+ };
513
+ var checkSourceOf = (body2, prefix) => {
514
+ if (body2[body2.length - 1] === SLASH) {
515
+ prefix = makeRegexPrefix(body2.slice(0, -1));
516
+ }
517
+ const head = prefix.slice(0, -1);
518
+ const last = prefix[prefix.length - 1];
519
+ return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
520
+ };
521
+ var matchesBasename = (body2) => {
522
+ const index = body2.indexOf(SLASH);
523
+ return index < 0 || index === body2.length - 1;
524
+ };
525
+ var basenameOf = (path) => {
526
+ const end = path.length - 1;
527
+ const index = path.lastIndexOf(
528
+ SLASH,
529
+ path[end] === SLASH ? end - 1 : end
530
+ );
531
+ return index < 0 ? path : path.slice(index + 1);
532
+ };
533
+ var parentOf = (path) => {
534
+ if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
535
+ const slices = path.split(SLASH).filter(Boolean);
536
+ slices.pop();
537
+ return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
538
+ }
539
+ const end = path.length - 1;
540
+ const cut = path.lastIndexOf(
541
+ SLASH,
542
+ path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
543
+ );
544
+ return cut < 0 ? EMPTY : path.slice(0, cut + 1);
231
545
  };
232
- var makeRegexPrefix = (pattern) => REPLACERS.reduce(
233
- (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
234
- pattern
235
- );
236
546
  var isString = (subject) => typeof subject === "string";
237
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
547
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
238
548
  var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
239
549
  var IgnoreRule = class {
240
550
  constructor(pattern, mark, body2, ignoreCase, negative, prefix) {
@@ -245,6 +555,14 @@ var require_ignore = __commonJS({
245
555
  define(this, "ignoreCase", ignoreCase);
246
556
  define(this, "regexPrefix", prefix);
247
557
  }
558
+ // Worked out on first use and kept behind an own property, the way `regex`
559
+ // caches itself in `_regex`. Deciding it in the constructor instead would
560
+ // add a fourth `defineProperty` to every rule ever built, which cost 4% of
561
+ // every compile -- including the compiles of rules that are never matched
562
+ // against anything.
563
+ get _basenameOnly() {
564
+ return define(this, "_basenameOnly", matchesBasename(this.body));
565
+ }
248
566
  get regex() {
249
567
  const key = UNDERSCORE + MODE_IGNORE;
250
568
  if (this[key]) {
@@ -260,24 +578,51 @@ var require_ignore = __commonJS({
260
578
  return this._make(MODE_CHECK_IGNORE, key);
261
579
  }
262
580
  _make(mode, key) {
263
- const str = this.regexPrefix.replace(
264
- REGEX_REPLACE_TRAILING_WILDCARD,
265
- // It does not need to bind pattern
266
- TRAILING_WILD_CARD_REPLACERS[mode]
581
+ const str = pinWildcards(
582
+ mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
267
583
  );
268
584
  const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
269
585
  return define(this, key, regex);
270
586
  }
271
587
  };
588
+ var isLineEnd = (char) => char === "\r" || char === "\n";
589
+ var trimEnd = (body2) => {
590
+ let end = body2.length;
591
+ while (end && isLineEnd(body2[end - 1])) {
592
+ end--;
593
+ }
594
+ const lineEnd = end;
595
+ while (end && body2[end - 1] === SPACE) {
596
+ end--;
597
+ }
598
+ if (end === lineEnd) {
599
+ return body2.slice(0, end);
600
+ }
601
+ let backslashes = 0;
602
+ while (backslashes < end && body2[end - backslashes - 1] === ESCAPE) {
603
+ backslashes++;
604
+ }
605
+ return backslashes % 2 ? body2.slice(0, end - 1) + SPACE : body2.slice(0, end);
606
+ };
272
607
  var createRule = ({
273
608
  pattern,
274
609
  mark
275
610
  }, ignoreCase) => {
611
+ let body2 = pattern[0] === BOM ? pattern.slice(1) : pattern;
612
+ if (body2[0] === "#") {
613
+ return;
614
+ }
276
615
  let negative = false;
277
- let body2 = pattern;
278
- if (body2.indexOf("!") === 0) {
616
+ if (body2[0] === "!") {
279
617
  negative = true;
280
- body2 = body2.substr(1);
618
+ body2 = body2.slice(1);
619
+ }
620
+ const last = body2[body2.length - 1];
621
+ if (last === SPACE || last === "\r" || last === "\n") {
622
+ body2 = trimEnd(body2);
623
+ }
624
+ if (!body2) {
625
+ return;
281
626
  }
282
627
  body2 = body2.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
283
628
  const regexPrefix = makeRegexPrefix(body2);
@@ -294,10 +639,12 @@ var require_ignore = __commonJS({
294
639
  constructor(ignoreCase) {
295
640
  this._ignoreCase = ignoreCase;
296
641
  this._rules = [];
642
+ this._basenameCount = 0;
297
643
  }
298
644
  _add(pattern) {
299
645
  if (pattern && pattern[KEY_IGNORE]) {
300
646
  this._rules = this._rules.concat(pattern._rules._rules);
647
+ this._basenameCount += pattern._rules._basenameCount;
301
648
  this._added = true;
302
649
  return;
303
650
  }
@@ -306,10 +653,13 @@ var require_ignore = __commonJS({
306
653
  pattern
307
654
  };
308
655
  }
309
- if (checkPattern(pattern.pattern)) {
310
- const rule = createRule(pattern, this._ignoreCase);
656
+ const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
657
+ if (rule) {
311
658
  this._added = true;
312
659
  this._rules.push(rule);
660
+ if (matchesBasename(rule.body)) {
661
+ this._basenameCount++;
662
+ }
313
663
  }
314
664
  }
315
665
  // @param {Array<string> | string | Ignore} pattern
@@ -318,8 +668,39 @@ var require_ignore = __commonJS({
318
668
  makeArray(
319
669
  isString(pattern) ? splitPattern(pattern) : pattern
320
670
  ).forEach(this._add, this);
671
+ if (this._added) {
672
+ this._literalRules = UNDEFINED;
673
+ }
321
674
  return this._added;
322
675
  }
676
+ // Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
677
+ // ending in a wildcard can match it (see `checkSourceOf`), so the rest
678
+ // are left out once, rather than tested or compiled for every path.
679
+ testLiteral(path) {
680
+ const rules = this._literalRules || (this._literalRules = this._rules.filter(
681
+ ({ body: body2 }) => body2[body2.length - (body2[body2.length - 1] === SLASH ? 2 : 1)] === "*"
682
+ ));
683
+ let ignored = false;
684
+ let unignored = false;
685
+ let matchedRule;
686
+ for (let index = rules.length - 1; index >= 0; index--) {
687
+ const rule = rules[index];
688
+ if (rule.checkRegex.test(path)) {
689
+ ignored = !rule.negative;
690
+ unignored = rule.negative;
691
+ matchedRule = rule.negative ? UNDEFINED : rule;
692
+ break;
693
+ }
694
+ }
695
+ const ret = {
696
+ ignored,
697
+ unignored
698
+ };
699
+ if (matchedRule) {
700
+ ret.rule = matchedRule;
701
+ }
702
+ return ret;
703
+ }
323
704
  // Test one single path without recursively checking parent directories
324
705
  //
325
706
  // - checkUnignored `boolean` whether should check if the path is unignored,
@@ -331,19 +712,22 @@ var require_ignore = __commonJS({
331
712
  let ignored = false;
332
713
  let unignored = false;
333
714
  let matchedRule;
334
- this._rules.forEach((rule) => {
715
+ const rules = this._rules;
716
+ const { length } = rules;
717
+ const shortcut = this._basenameCount * 2 >= length;
718
+ const basename = shortcut ? basenameOf(path) : path;
719
+ for (let index = 0; index < length; index++) {
720
+ const rule = rules[index];
335
721
  const { negative } = rule;
336
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
337
- return;
722
+ const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
723
+ if (!skip && rule[mode].test(
724
+ shortcut && rule._basenameOnly ? basename : path
725
+ )) {
726
+ ignored = !negative;
727
+ unignored = negative;
728
+ matchedRule = negative ? UNDEFINED : rule;
338
729
  }
339
- const matched = rule[mode].test(path);
340
- if (!matched) {
341
- return;
342
- }
343
- ignored = !negative;
344
- unignored = negative;
345
- matchedRule = negative ? UNDEFINED : rule;
346
- });
730
+ }
347
731
  const ret = {
348
732
  ignored,
349
733
  unignored
@@ -376,7 +760,26 @@ var require_ignore = __commonJS({
376
760
  }
377
761
  return true;
378
762
  };
379
- var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
763
+ var isNotRelative = (path) => {
764
+ const first = path.charCodeAt(0);
765
+ if (first === SLASH_CODE) {
766
+ return true;
767
+ }
768
+ if (first !== DOT_CODE) {
769
+ return false;
770
+ }
771
+ if (path.length === 1) {
772
+ return true;
773
+ }
774
+ const second = path.charCodeAt(1);
775
+ if (second === SLASH_CODE) {
776
+ return true;
777
+ }
778
+ if (second !== DOT_CODE) {
779
+ return false;
780
+ }
781
+ return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
782
+ };
380
783
  checkPath.isNotRelative = isNotRelative;
381
784
  checkPath.convert = (p) => p;
382
785
  var Ignore = class {
@@ -405,52 +808,33 @@ var require_ignore = __commonJS({
405
808
  return this.add(pattern);
406
809
  }
407
810
  // @returns {TestResult}
408
- _test(originalPath, cache, checkUnignored, slices) {
811
+ _test(originalPath, cache, checkUnignored) {
409
812
  const path = originalPath && checkPath.convert(originalPath);
410
813
  checkPath(
411
814
  path,
412
815
  originalPath,
413
816
  this._strictPathCheck ? throwError : RETURN_FALSE
414
817
  );
415
- return this._t(path, cache, checkUnignored, slices);
818
+ return this._t(path, cache, checkUnignored);
416
819
  }
417
820
  checkIgnore(path) {
418
- if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
821
+ if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
419
822
  return this.test(path);
420
823
  }
421
- const slices = path.split(SLASH).filter(Boolean);
422
- slices.pop();
423
- if (slices.length) {
424
- const parent = this._t(
425
- slices.join(SLASH) + SLASH,
426
- this._testCache,
427
- true,
428
- slices
429
- );
430
- if (parent.ignored) {
431
- return parent;
432
- }
824
+ const dir = this._t(path, this._testCache, true);
825
+ if (dir.ignored) {
826
+ return dir;
433
827
  }
434
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
828
+ const literal = this._rules.testLiteral(path);
829
+ return literal.ignored || literal.unignored ? literal : dir;
435
830
  }
436
- _t(path, cache, checkUnignored, slices) {
831
+ _t(path, cache, checkUnignored) {
437
832
  if (path in cache) {
438
833
  return cache[path];
439
834
  }
440
- if (!slices) {
441
- slices = path.split(SLASH).filter(Boolean);
442
- }
443
- slices.pop();
444
- if (!slices.length) {
445
- return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
446
- }
447
- const parent = this._t(
448
- slices.join(SLASH) + SLASH,
449
- cache,
450
- checkUnignored,
451
- slices
452
- );
453
- return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
835
+ const parentPath = parentOf(path);
836
+ const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
837
+ return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
454
838
  }
455
839
  ignores(path) {
456
840
  return this._test(path, this._ignoreCache, false).ignored;
@@ -652,6 +1036,18 @@ function setModule(module2) {
652
1036
  }
653
1037
  __name(setModule, "setModule");
654
1038
  var C;
1039
+ function newFinalizer(handler) {
1040
+ try {
1041
+ return new FinalizationRegistry(handler);
1042
+ } catch (e) {
1043
+ console.error("Unsupported FinalizationRegistry:", e);
1044
+ return;
1045
+ }
1046
+ }
1047
+ __name(newFinalizer, "newFinalizer");
1048
+ var finalizer = newFinalizer((address) => {
1049
+ C._ts_lookahead_iterator_delete(address);
1050
+ });
655
1051
  var LookaheadIterator = class {
656
1052
  static {
657
1053
  __name(this, "LookaheadIterator");
@@ -662,21 +1058,39 @@ var LookaheadIterator = class {
662
1058
  /** @internal */
663
1059
  language;
664
1060
  /** @internal */
1061
+ positioned = false;
1062
+ /** @internal */
665
1063
  constructor(internal, address, language) {
666
1064
  assertInternal(internal);
667
1065
  this[0] = address;
668
1066
  this.language = language;
1067
+ finalizer?.register(this, address, this);
669
1068
  }
670
- /** Get the current symbol of the lookahead iterator. */
1069
+ /**
1070
+ * Get the current symbol of the lookahead iterator.
1071
+ *
1072
+ * Returns `null` if the iterator is not positioned on a symbol:
1073
+ *
1074
+ * - Before the first iteration step
1075
+ * - After the iterator is exhausted
1076
+ * - After a {@link reset} or {@link resetState} call
1077
+ */
671
1078
  get currentTypeId() {
672
- return C._ts_lookahead_iterator_current_symbol(this[0]);
1079
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
673
1080
  }
674
- /** Get the current symbol name of the lookahead iterator. */
1081
+ /**
1082
+ * Get the current symbol name of the lookahead iterator.
1083
+ *
1084
+ * Returns `null` if the iterator is not positioned on a symbol.
1085
+ */
675
1086
  get currentType() {
676
- return this.language.types[this.currentTypeId] || "ERROR";
1087
+ const id = this.currentTypeId;
1088
+ if (id === null) return null;
1089
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
677
1090
  }
678
1091
  /** Delete the lookahead iterator, freeing its resources. */
679
1092
  delete() {
1093
+ finalizer?.unregister(this);
680
1094
  C._ts_lookahead_iterator_delete(this[0]);
681
1095
  this[0] = 0;
682
1096
  }
@@ -689,6 +1103,7 @@ var LookaheadIterator = class {
689
1103
  reset(language, stateId) {
690
1104
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
691
1105
  this.language = language;
1106
+ this.positioned = false;
692
1107
  return true;
693
1108
  }
694
1109
  return false;
@@ -700,7 +1115,9 @@ var LookaheadIterator = class {
700
1115
  * `false` otherwise.
701
1116
  */
702
1117
  resetState(stateId) {
703
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
1118
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
1119
+ this.positioned = false;
1120
+ return true;
704
1121
  }
705
1122
  /**
706
1123
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -711,10 +1128,9 @@ var LookaheadIterator = class {
711
1128
  [Symbol.iterator]() {
712
1129
  return {
713
1130
  next: /* @__PURE__ */ __name(() => {
714
- if (C._ts_lookahead_iterator_next(this[0])) {
715
- return { done: false, value: this.currentType };
716
- }
717
- return { done: true, value: "" };
1131
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
1132
+ const value = this.currentType;
1133
+ return value === null ? { done: true, value: "" } : { done: false, value };
718
1134
  }, "next")
719
1135
  };
720
1136
  }
@@ -740,6 +1156,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
740
1156
  return result ?? "";
741
1157
  }
742
1158
  __name(getText, "getText");
1159
+ var finalizer2 = newFinalizer((address) => {
1160
+ C._ts_tree_delete(address);
1161
+ });
743
1162
  var Tree = class _Tree {
744
1163
  static {
745
1164
  __name(this, "Tree");
@@ -757,6 +1176,7 @@ var Tree = class _Tree {
757
1176
  this[0] = address;
758
1177
  this.language = language;
759
1178
  this.textCallback = textCallback;
1179
+ finalizer2?.register(this, address, this);
760
1180
  }
761
1181
  /** Create a shallow copy of the syntax tree. This is very fast. */
762
1182
  copy() {
@@ -765,6 +1185,7 @@ var Tree = class _Tree {
765
1185
  }
766
1186
  /** Delete the syntax tree, freeing its resources. */
767
1187
  delete() {
1188
+ finalizer2?.unregister(this);
768
1189
  C._ts_tree_delete(this[0]);
769
1190
  this[0] = 0;
770
1191
  }
@@ -845,6 +1266,9 @@ var Tree = class _Tree {
845
1266
  return result;
846
1267
  }
847
1268
  };
1269
+ var finalizer3 = newFinalizer((address) => {
1270
+ C._ts_tree_cursor_delete_wasm(address);
1271
+ });
848
1272
  var TreeCursor = class _TreeCursor {
849
1273
  static {
850
1274
  __name(this, "TreeCursor");
@@ -872,6 +1296,7 @@ var TreeCursor = class _TreeCursor {
872
1296
  assertInternal(internal);
873
1297
  this.tree = tree;
874
1298
  unmarshalTreeCursor(this);
1299
+ finalizer3?.register(this, this.tree[0], this);
875
1300
  }
876
1301
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
877
1302
  copy() {
@@ -882,6 +1307,7 @@ var TreeCursor = class _TreeCursor {
882
1307
  }
883
1308
  /** Delete the tree cursor, freeing its resources. */
884
1309
  delete() {
1310
+ finalizer3?.unregister(this);
885
1311
  marshalTreeCursor(this);
886
1312
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
887
1313
  this[0] = this[1] = this[2] = 0;
@@ -1976,8 +2402,9 @@ var Language = class _Language {
1976
2402
  * This returns `null` if state is invalid for this language.
1977
2403
  *
1978
2404
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
1979
- * parse state. Newly created lookahead iterators will return the `ERROR`
1980
- * symbol from {@link LookaheadIterator#currentType}.
2405
+ * parse state. A newly created iterator is not positioned on a symbol, so
2406
+ * {@link LookaheadIterator#currentType} returns `null` until the first
2407
+ * iteration step.
1981
2408
  *
1982
2409
  * Lookahead iterators can be useful for generating suggestions and improving
1983
2410
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -1992,7 +2419,8 @@ var Language = class _Language {
1992
2419
  }
1993
2420
  /**
1994
2421
  * Load a language from a WebAssembly module.
1995
- * The module can be provided as a path to a file or as a buffer.
2422
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
2423
+ * buffer.
1996
2424
  */
1997
2425
  static async load(input) {
1998
2426
  let binary2;
@@ -2019,16 +2447,27 @@ ${body2}`);
2019
2447
  }
2020
2448
  }
2021
2449
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
2450
+ return _Language.loadFromWasmExports(mod, { sync: false });
2451
+ }
2452
+ static loadFromWasmExports(mod, { sync }) {
2022
2453
  const symbolNames = Object.keys(mod);
2023
2454
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
2024
2455
  if (!functionName) {
2025
2456
  console.log(`Couldn't find language function in Wasm file. Symbols:
2026
2457
  ${JSON.stringify(symbolNames, null, 2)}`);
2027
- throw new Error("Language.load failed: no language function found in Wasm file");
2458
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
2028
2459
  }
2029
2460
  const languageAddress = mod[functionName]();
2030
2461
  return new _Language(INTERNAL, languageAddress);
2031
2462
  }
2463
+ /**
2464
+ * Load a language synchronously from a pre-compiled WebAssembly module.
2465
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
2466
+ */
2467
+ static loadSync(wasmModule) {
2468
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
2469
+ return _Language.loadFromWasmExports(mod, { sync: true });
2470
+ }
2032
2471
  };
2033
2472
  async function Module2(moduleArg = {}) {
2034
2473
  var moduleRtn;
@@ -2551,7 +2990,7 @@ async function Module2(moduleArg = {}) {
2551
2990
  newDSO("__main__", 0, wasmImports);
2552
2991
  }
2553
2992
  };
2554
- var ___heap_base = 78240;
2993
+ var ___heap_base = 82240;
2555
2994
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
2556
2995
  var getMemory = /* @__PURE__ */ __name((size) => {
2557
2996
  if (runtimeInitialized) {
@@ -3116,12 +3555,12 @@ async function Module2(moduleArg = {}) {
3116
3555
  "value": "i32",
3117
3556
  "mutable": false
3118
3557
  }, 1024);
3119
- var ___stack_high = 78240;
3120
- var ___stack_low = 12704;
3558
+ var ___stack_high = 82240;
3559
+ var ___stack_low = 16704;
3121
3560
  var ___stack_pointer = new WebAssembly.Global({
3122
3561
  "value": "i32",
3123
3562
  "mutable": true
3124
- }, 78240);
3563
+ }, 82240);
3125
3564
  var ___table_base = new WebAssembly.Global({
3126
3565
  "value": "i32",
3127
3566
  "mutable": false
@@ -3382,7 +3821,7 @@ async function Module2(moduleArg = {}) {
3382
3821
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
3383
3822
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
3384
3823
  var ASM_CONSTS = {};
3385
- 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;
3824
+ 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;
3386
3825
  function assignWasmExports(wasmExports2) {
3387
3826
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
3388
3827
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -3416,6 +3855,7 @@ async function Module2(moduleArg = {}) {
3416
3855
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
3417
3856
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
3418
3857
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
3858
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
3419
3859
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
3420
3860
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
3421
3861
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -3521,6 +3961,7 @@ async function Module2(moduleArg = {}) {
3521
3961
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
3522
3962
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
3523
3963
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
3964
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
3524
3965
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
3525
3966
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
3526
3967
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -3658,6 +4099,10 @@ __name(checkModule, "checkModule");
3658
4099
  var TRANSFER_BUFFER;
3659
4100
  var LANGUAGE_VERSION;
3660
4101
  var MIN_COMPATIBLE_VERSION;
4102
+ var finalizer4 = newFinalizer((addresses) => {
4103
+ C._ts_parser_delete(addresses[0]);
4104
+ C._free(addresses[1]);
4105
+ });
3661
4106
  var Parser = class {
3662
4107
  static {
3663
4108
  __name(this, "Parser");
@@ -3689,6 +4134,7 @@ var Parser = class {
3689
4134
  */
3690
4135
  constructor() {
3691
4136
  this.initialize();
4137
+ finalizer4?.register(this, [this[0], this[1]], this);
3692
4138
  }
3693
4139
  /** @internal */
3694
4140
  initialize() {
@@ -3701,6 +4147,7 @@ var Parser = class {
3701
4147
  }
3702
4148
  /** Delete the parser, freeing its resources. */
3703
4149
  delete() {
4150
+ finalizer4?.unregister(this);
3704
4151
  C._ts_parser_delete(this[0]);
3705
4152
  C._free(this[1]);
3706
4153
  this[0] = 0;
@@ -3876,6 +4323,10 @@ var QueryError = class _QueryError extends Error {
3876
4323
  this.length = length;
3877
4324
  this.name = "QueryError";
3878
4325
  }
4326
+ kind;
4327
+ info;
4328
+ index;
4329
+ length;
3879
4330
  static {
3880
4331
  __name(this, "QueryError");
3881
4332
  }
@@ -4071,6 +4522,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
4071
4522
  }
4072
4523
  }
4073
4524
  __name(parsePattern, "parsePattern");
4525
+ var finalizer5 = newFinalizer((address) => {
4526
+ C._ts_query_delete(address);
4527
+ });
4074
4528
  var Query = class {
4075
4529
  static {
4076
4530
  __name(this, "Query");
@@ -4225,9 +4679,11 @@ var Query = class {
4225
4679
  this.assertedProperties = assertedProperties;
4226
4680
  this.refutedProperties = refutedProperties;
4227
4681
  this.exceededMatchLimit = false;
4682
+ finalizer5?.register(this, address, this);
4228
4683
  }
4229
4684
  /** Delete the query, freeing its resources. */
4230
4685
  delete() {
4686
+ finalizer5?.unregister(this);
4231
4687
  C._ts_query_delete(this[0]);
4232
4688
  this[0] = 0;
4233
4689
  }