@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.
package/dist/project.js CHANGED
@@ -53,13 +53,15 @@ var require_ignore = __commonJS({
53
53
  var EMPTY = "";
54
54
  var SPACE = " ";
55
55
  var ESCAPE = "\\";
56
- var REGEX_TEST_BLANK_LINE = /^\s+$/;
56
+ var REGEX_LITERAL_SPECIAL = /[.*+?()[\]{}^$|\\/]/;
57
+ var BOM = "\uFEFF";
57
58
  var REGEX_INVALID_TRAILING_BACKSLASH = /(?:[^\\]|^)\\$/;
58
59
  var REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION = /^\\!/;
59
60
  var REGEX_REPLACE_LEADING_EXCAPED_HASH = /^\\#/;
60
61
  var REGEX_SPLITALL_CRLF = /\r?\n/g;
61
- var REGEX_TEST_INVALID_PATH = /^\.{0,2}\/|^\.{1,2}$/;
62
- var REGEX_TEST_TRAILING_SLASH = /\/$/;
62
+ var DOUBLE_SLASH = "//";
63
+ var SLASH_CODE = 47;
64
+ var DOT_CODE = 46;
63
65
  var SLASH = "/";
64
66
  var TMP_KEY_IGNORE = "node-ignore";
65
67
  if (typeof Symbol !== "undefined") {
@@ -70,44 +72,173 @@ var require_ignore = __commonJS({
70
72
  Object.defineProperty(object, key, { value });
71
73
  return value;
72
74
  };
73
- var REGEX_REGEXP_RANGE = /([0-z])-([0-z])/g;
74
75
  var RETURN_FALSE = () => false;
75
- var sanitizeRange = (range) => range.replace(
76
- REGEX_REGEXP_RANGE,
77
- (match, from, to) => from.charCodeAt(0) <= to.charCodeAt(0) ? match : EMPTY
78
- );
79
- var negateRange = (range) => range.startsWith("!") || range.startsWith("\\^") ? `^${range.slice(range[0] === "!" ? 1 : 2)}` : range;
80
76
  var cleanRangeBackSlash = (slashes) => {
81
77
  const { length } = slashes;
82
78
  return slashes.slice(0, length - length % 2);
83
79
  };
80
+ var POSIX_CLASSES = {
81
+ alnum: "0-9A-Za-z",
82
+ alpha: "A-Za-z",
83
+ blank: " \\t",
84
+ cntrl: "\\x00-\\x1f\\x7f",
85
+ digit: "0-9",
86
+ graph: "!-.0-~",
87
+ lower: "a-z",
88
+ print: " -.0-~",
89
+ punct: "!-.:-@\\[-`{-~",
90
+ // git's `sane-ctype.h` classifies \v and \f as control, not space,
91
+ // unlike C's `isspace`
92
+ space: " \\t\\n\\r",
93
+ upper: "A-Z",
94
+ xdigit: "0-9A-Fa-f"
95
+ };
96
+ var CLASS_MEMBERS_TO_ESCAPE = "\\]^-[";
97
+ var escapeMember = (char) => CLASS_MEMBERS_TO_ESCAPE.indexOf(char) < 0 ? char : ESCAPE + char;
98
+ var NON_SLASH = "(?!\\/)";
99
+ var classSource = (negated, body2) => {
100
+ if (negated) {
101
+ return `[^\\/${body2}]`;
102
+ }
103
+ const source = `[${body2}]`;
104
+ return new RegExp(source).test("/") ? NON_SLASH + source : source;
105
+ };
106
+ var scanBracket = (pattern, start2) => {
107
+ const { length } = pattern;
108
+ let index = start2 + 1;
109
+ let negated = EMPTY;
110
+ const lead = pattern[index];
111
+ if (lead === "!" || lead === "^") {
112
+ negated = "^";
113
+ index++;
114
+ }
115
+ let body2 = EMPTY;
116
+ let prev = EMPTY;
117
+ for (; ; ) {
118
+ const char = pattern[index];
119
+ if (char === UNDEFINED) {
120
+ return null;
121
+ }
122
+ if (char === ESCAPE) {
123
+ const escaped = pattern[index + 1];
124
+ if (escaped === UNDEFINED) {
125
+ return null;
126
+ }
127
+ body2 += escapeMember(escaped);
128
+ prev = escaped;
129
+ index++;
130
+ } else if (char === "-" && prev && index + 1 < length && pattern[index + 1] !== "]") {
131
+ index++;
132
+ let to = pattern[index];
133
+ if (to === ESCAPE) {
134
+ to = pattern[index += 1];
135
+ }
136
+ if (prev <= to) {
137
+ body2 += `-${escapeMember(to)}`;
138
+ }
139
+ prev = EMPTY;
140
+ } else if (char === "[" && pattern[index + 1] === ":") {
141
+ const nameStart = index + 2;
142
+ let end = nameStart;
143
+ while (end < length && pattern[end] !== "]") {
144
+ end++;
145
+ }
146
+ if (end === length) {
147
+ return null;
148
+ }
149
+ if (end > nameStart && pattern[end - 1] === ":") {
150
+ const expanded = POSIX_CLASSES[pattern.slice(nameStart, end - 1)];
151
+ if (expanded === UNDEFINED) {
152
+ return null;
153
+ }
154
+ body2 += expanded;
155
+ prev = EMPTY;
156
+ index = end;
157
+ } else {
158
+ body2 += escapeMember("[");
159
+ prev = "[";
160
+ index = nameStart - 2;
161
+ }
162
+ } else {
163
+ body2 += escapeMember(char);
164
+ prev = char;
165
+ }
166
+ index++;
167
+ if (pattern[index] === "]") {
168
+ return {
169
+ end: index,
170
+ source: classSource(negated, body2)
171
+ };
172
+ }
173
+ }
174
+ };
175
+ var NEVER_MATCH = "[]";
176
+ var PLACEHOLDER = "\0";
177
+ var REGEX_RESTORE_PLACEHOLDER = new RegExp(
178
+ `${PLACEHOLDER}(\\d+)${PLACEHOLDER}`,
179
+ "g"
180
+ );
181
+ var TRAILING_WILDCARD = "\uE000";
182
+ var TRAILING_DOUBLESTAR = "\uE001";
183
+ var extractBrackets = (pattern) => {
184
+ const sources = [];
185
+ const hold = (source) => `${PLACEHOLDER}${sources.push(source) - 1}${PLACEHOLDER}`;
186
+ const { length } = pattern;
187
+ let out2 = EMPTY;
188
+ let index = 0;
189
+ while (index < length) {
190
+ const char = pattern[index];
191
+ if (char === ESCAPE) {
192
+ const escaped = pattern[index + 1];
193
+ if (escaped === UNDEFINED || escaped === SLASH && index + 2 === length) {
194
+ out2 += hold(NEVER_MATCH);
195
+ } else if (escaped === "*" || escaped === "[" || escaped === SPACE || escaped === ESCAPE) {
196
+ out2 += pattern.slice(index, index + 2);
197
+ } else {
198
+ out2 += hold(
199
+ REGEX_LITERAL_SPECIAL.test(escaped) ? ESCAPE + escaped : escaped
200
+ );
201
+ }
202
+ index += 2;
203
+ } else if (char === PLACEHOLDER) {
204
+ out2 += hold(`[${PLACEHOLDER}]`);
205
+ index++;
206
+ } else if (char === "[") {
207
+ const scanned = scanBracket(pattern, index);
208
+ if (scanned === null) {
209
+ out2 += hold(NEVER_MATCH);
210
+ index = length;
211
+ } else {
212
+ out2 += hold(scanned.source);
213
+ index = scanned.end + 1;
214
+ }
215
+ } else {
216
+ out2 += char;
217
+ index++;
218
+ }
219
+ }
220
+ return {
221
+ source: out2,
222
+ sources
223
+ };
224
+ };
225
+ var DIRECT = null;
226
+ var REGEX_INNER_SLASH = /\/(?!$)/;
84
227
  var REPLACERS = [
85
- [
86
- // Remove BOM
87
- // TODO:
88
- // Other similar zero-width characters?
89
- /^\uFEFF/,
90
- () => EMPTY
91
- ],
92
- // > Trailing spaces are ignored unless they are quoted with backslash ("\")
93
- [
94
- // (a\ ) -> (a )
95
- // (a ) -> (a)
96
- // (a ) -> (a)
97
- // (a \ ) -> (a )
98
- /((?:\\\\)*?)(\\?\s+)$/,
99
- (_, m1, m2) => m1 + (m2.indexOf("\\") === 0 ? SPACE : EMPTY)
100
- ],
101
228
  // Replace (\ ) with ' '
229
+ // Only a space: an escaped tab or other whitespace is already a literal by
230
+ // the time it reaches here, and a bare tab must be left as one, not turned
231
+ // into a space.
102
232
  // (\ ) -> ' '
103
233
  // (\\ ) -> '\\ '
104
234
  // (\\\ ) -> '\\ '
105
235
  [
106
- /(\\+?)\s/g,
107
- (_, m1) => {
108
- const { length } = m1;
109
- return m1.slice(0, length - length % 2) + SPACE;
110
- }
236
+ // A run of backslashes is taken whole, from its first one, so no match
237
+ // ever starts again inside it -- `(\\+?) ` did, which made a long run
238
+ // quadratic.
239
+ /(\\+)( ?)/g,
240
+ (_, run2, space) => space ? run2.slice(0, run2.length - run2.length % 2) + SPACE : run2,
241
+ ESCAPE + SPACE
111
242
  ],
112
243
  // Escape metacharacters
113
244
  // which is written down by users but means special for regular expressions.
@@ -132,7 +263,8 @@ var require_ignore = __commonJS({
132
263
  [
133
264
  // > a question mark (?) matches a single character
134
265
  /(?!\\)\?/g,
135
- () => "[^/]"
266
+ () => "[^/]",
267
+ "?"
136
268
  ],
137
269
  // leading slash
138
270
  [
@@ -140,12 +272,14 @@ var require_ignore = __commonJS({
140
272
  // > For example, "/*.c" matches "cat-file.c" but not "mozilla-sha1/sha1.c".
141
273
  // A leading slash matches the beginning of the pathname
142
274
  /^\//,
143
- () => "^"
275
+ () => "^",
276
+ SLASH
144
277
  ],
145
278
  // replace special metacharacter slash after the leading slash
146
279
  [
147
280
  /\//g,
148
- () => "\\/"
281
+ () => "\\/",
282
+ SLASH
149
283
  ],
150
284
  [
151
285
  // > A leading "**" followed by a slash means match in all directories.
@@ -156,16 +290,21 @@ var require_ignore = __commonJS({
156
290
  // Notice that the '*'s have been replaced as '\\*'
157
291
  /^\^*(?:\\\*\\\*\\\/)+/,
158
292
  // '**/foo' <-> 'foo'
159
- () => "^(?:.*\\/)?"
293
+ () => "^(?:.*\\/)?",
294
+ "*"
160
295
  ],
161
296
  // starting
162
297
  [
163
298
  // there will be no leading '/'
164
299
  // (which has been replaced by section "leading slash")
165
300
  // If starts with '**', adding a '^' to the regular expression also works
166
- /^(?=[^^])/,
167
- function startingReplacer() {
168
- return !/\/(?!$)/.test(this) ? "(?:^|\\/)" : "^";
301
+ DIRECT,
302
+ (source, pattern) => {
303
+ if (!source || source[0] === "^") {
304
+ return source;
305
+ }
306
+ const anchor = !REGEX_INNER_SLASH.test(pattern) ? "(?:^|\\/)" : "^";
307
+ return anchor + source;
169
308
  }
170
309
  ],
171
310
  // two globstars
@@ -175,7 +314,8 @@ var require_ignore = __commonJS({
175
314
  // Zero, one or several directories
176
315
  // should not use '*', or it will be replaced by the next replacer
177
316
  // Check if it is not the last `'/**'`
178
- (_, index, str) => index + 6 < str.length ? "(?:\\/[^\\/]+)*" : "\\/.+"
317
+ (_, index, str) => index + 6 < str.length ? str.slice(index + 6) === "\\/" ? "(?:\\/[^\\/]+)+" : "(?:\\/[^\\/]+)*" : `\\/${TRAILING_DOUBLESTAR}`,
318
+ "*"
179
319
  ],
180
320
  // normal intermediate wildcards
181
321
  [
@@ -190,32 +330,56 @@ var require_ignore = __commonJS({
190
330
  (_, p1, p2) => {
191
331
  const unescaped = p2.replace(/\\\*/g, "[^\\/]*");
192
332
  return p1 + unescaped;
193
- }
333
+ },
334
+ "*"
335
+ ],
336
+ // trailing wildcard, held apart from a literal star
337
+ [
338
+ // The step above leaves a trailing `*` alone, so a single `\*` is all that
339
+ // can be left at the end here. Whether it is a wildcard or a literal
340
+ // turns on the backslashes the user put in front of it: the escaper has
341
+ // since doubled every one, so what stands here is those `2N` doubled
342
+ // backslashes and then the star's own escape. An even number of the
343
+ // original `N` leaves the star unescaped -- a wildcard -- and an odd
344
+ // number escapes it -- a literal. This runs while the two are still
345
+ // distinct, before the unescape steps below collapse the literal onto
346
+ // the very `\*` a wildcard leaves behind.
347
+ /(^|[^\\])((?:\\\\)*)\\\*$/,
348
+ (match, p1, p2) => (
349
+ // `p2` holds the doubled user backslashes; half of them is `N`.
350
+ p2.length / 2 % 2 === 0 ? p1 + p2 + TRAILING_WILDCARD : match
351
+ ),
352
+ "*"
194
353
  ],
195
354
  [
196
355
  // unescape, revert step 3 except for back slash
197
356
  // For example, if a user escape a '\\*',
198
357
  // after step 3, the result will be '\\\\\\*'
199
358
  /\\\\\\(?=[$.|*+(){^])/g,
200
- () => ESCAPE
359
+ () => ESCAPE,
360
+ ESCAPE + ESCAPE
201
361
  ],
202
362
  [
203
363
  // '\\\\' -> '\\'
204
364
  /\\\\/g,
205
- () => ESCAPE
365
+ () => ESCAPE,
366
+ ESCAPE + ESCAPE
206
367
  ],
207
368
  [
208
- // > The range notation, e.g. [a-zA-Z],
209
- // > can be used to match one of the characters in a range.
369
+ // Every real bracket expression -- POSIX classes included -- has already
370
+ // been held aside by `extractBrackets`, so the only `[` left in the
371
+ // pattern is an escaped, literal one.
210
372
  // `\` is escaped by step 3
211
- /(\\)?\[([^\]/]*?)(\\*)($|\])/g,
212
- (match, leadEscape, range, endEscape, close) => leadEscape === ESCAPE ? `\\[${range}${cleanRangeBackSlash(endEscape)}${close}` : close === "]" ? endEscape.length % 2 === 0 ? `[${negateRange(sanitizeRange(range))}${endEscape}]` : "[]" : "[]"
373
+ /\\\[([^\]/]*?)(\\*)($|\])/g,
374
+ // '\\[bar]' -> '\\\\[bar\\]'
375
+ (match, range, endEscape, close) => `\\[${range}${cleanRangeBackSlash(endEscape)}${close}`,
376
+ "["
213
377
  ],
214
378
  // ending
215
379
  [
216
380
  // 'js' will not match 'js.'
217
381
  // 'ab' will not match 'abc'
218
- /(?:[^*])$/,
382
+ DIRECT,
219
383
  // WTF!
220
384
  // https://git-scm.com/docs/gitignore
221
385
  // changes in [2.22.1](https://git-scm.com/docs/gitignore/2.22.1)
@@ -226,29 +390,175 @@ var require_ignore = __commonJS({
226
390
  // 'js*' will not match 'a.js'
227
391
  // 'js/' will not match 'a.js'
228
392
  // 'js' will match 'a.js' and 'a.js/'
229
- (match) => /\/$/.test(match) ? `${match}$` : `${match}(?=$|\\/$)`
393
+ (source) => {
394
+ const last = source[source.length - 1];
395
+ if (!last || last === TRAILING_WILDCARD || last === TRAILING_DOUBLESTAR) {
396
+ return source;
397
+ }
398
+ return last === SLASH ? `${source}$` : `${source}(?=$|\\/$)`;
399
+ }
230
400
  ]
231
401
  ];
232
- var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\\\*$/;
402
+ var REGEX_REPLACE_TRAILING_WILDCARD = /(^|\\\/)?\uE000$/;
233
403
  var MODE_IGNORE = "regex";
234
404
  var MODE_CHECK_IGNORE = "checkRegex";
235
405
  var UNDERSCORE = "_";
236
- var TRAILING_WILD_CARD_REPLACERS = {
237
- [MODE_IGNORE](_, p1) {
238
- const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
239
- return `${prefix}(?=$|\\/$)`;
240
- },
241
- [MODE_CHECK_IGNORE](_, p1) {
242
- const prefix = p1 ? `${p1}[^/]*` : "[^/]*";
243
- return `${prefix}(?=$|\\/$)`;
406
+ var replaceTrailingWildcard = (_, p1) => {
407
+ const prefix = p1 ? `${p1}[^/]+` : "[^/]*";
408
+ return `${prefix}(?=$|\\/$)`;
409
+ };
410
+ var REGEX_REPLACE_TRAILING_DOUBLESTAR = /\uE001$/;
411
+ var replaceTrailingDoublestar = () => ".+(?=$|\\/$)";
412
+ var WILDCARD = "[^\\/]*";
413
+ var separatorAfter = (run2, at) => {
414
+ let separator = EMPTY;
415
+ for (let index = at + 1; index < run2.length && !run2[index].wildcard; index++) {
416
+ separator += run2[index].single;
417
+ }
418
+ return separator;
419
+ };
420
+ var pinWildcards = (source) => {
421
+ if (source.indexOf(WILDCARD) < 0) {
422
+ return source;
423
+ }
424
+ const tokens = [];
425
+ const { length } = source;
426
+ let index = 0;
427
+ while (index < length) {
428
+ const char = source[index];
429
+ if (source.startsWith(WILDCARD, index)) {
430
+ tokens.push({ wildcard: true });
431
+ index += WILDCARD.length;
432
+ } else if (char === "[") {
433
+ let end = index + 1;
434
+ if (source[end] === "^") {
435
+ end++;
436
+ }
437
+ if (source[end] === "]") {
438
+ end++;
439
+ }
440
+ while (end < length && source[end] !== "]") {
441
+ end += source[end] === ESCAPE ? 2 : 1;
442
+ }
443
+ end++;
444
+ tokens.push({ single: source.slice(index, end) });
445
+ index = end;
446
+ } else if (char === ESCAPE) {
447
+ tokens.push({ single: source.slice(index, index + 2) });
448
+ index += 2;
449
+ } else if (char === "(") {
450
+ let depth = 0;
451
+ let end = index;
452
+ do {
453
+ if (source[end] === ESCAPE) {
454
+ end++;
455
+ } else if (source[end] === "(") {
456
+ depth++;
457
+ } else if (source[end] === ")") {
458
+ depth--;
459
+ }
460
+ end++;
461
+ } while (end < length && depth > 0);
462
+ if ("*+?".indexOf(source[end]) >= 0) {
463
+ end++;
464
+ }
465
+ tokens.push({ boundary: source.slice(index, end) });
466
+ index = end;
467
+ } else if (char === "^" || char === "$") {
468
+ tokens.push({ boundary: char });
469
+ index++;
470
+ } else {
471
+ tokens.push({ single: char });
472
+ index++;
473
+ }
474
+ }
475
+ let out2 = EMPTY;
476
+ let run2 = [];
477
+ const flush = () => {
478
+ let lastWildcard;
479
+ run2.forEach((token, at) => {
480
+ if (token.wildcard) {
481
+ lastWildcard = at;
482
+ }
483
+ });
484
+ run2.forEach((token, at) => {
485
+ if (!token.wildcard) {
486
+ out2 += token.single;
487
+ return;
488
+ }
489
+ out2 += at === lastWildcard ? WILDCARD : `(?:(?!${separatorAfter(run2, at)})[^\\/])*`;
490
+ });
491
+ run2 = [];
492
+ };
493
+ tokens.forEach((token) => {
494
+ if (token.boundary === void 0) {
495
+ run2.push(token);
496
+ return;
497
+ }
498
+ flush();
499
+ out2 += token.boundary;
500
+ });
501
+ flush();
502
+ return out2;
503
+ };
504
+ var makeRegexPrefix = (pattern) => {
505
+ const { source, sources } = extractBrackets(pattern);
506
+ const replaced = REPLACERS.reduce(
507
+ // A pass whose matcher finds nothing hands back the very string it was
508
+ // given, so asking first costs a search and saves a rewrite. Ten of the
509
+ // fifteen passes never fire for a typical .gitignore line, and between
510
+ // them they were 45% of this chain.
511
+ (prev, [matcher, replacer, required]) => {
512
+ if (matcher === DIRECT) {
513
+ return replacer(prev, pattern);
514
+ }
515
+ if (required !== UNDEFINED && prev.indexOf(required) < 0) {
516
+ return prev;
517
+ }
518
+ return matcher.test(prev) ? prev.replace(matcher, replacer.bind(pattern)) : prev;
519
+ },
520
+ source
521
+ );
522
+ return sources.length ? replaced.replace(
523
+ REGEX_RESTORE_PLACEHOLDER,
524
+ (match, index) => sources[index]
525
+ ) : replaced;
526
+ };
527
+ var checkSourceOf = (body2, prefix) => {
528
+ if (body2[body2.length - 1] === SLASH) {
529
+ prefix = makeRegexPrefix(body2.slice(0, -1));
244
530
  }
531
+ const head = prefix.slice(0, -1);
532
+ const last = prefix[prefix.length - 1];
533
+ return last === TRAILING_WILDCARD ? `${head}$` : last === TRAILING_DOUBLESTAR ? `${head}.*$` : NEVER_MATCH;
534
+ };
535
+ var matchesBasename = (body2) => {
536
+ const index = body2.indexOf(SLASH);
537
+ return index < 0 || index === body2.length - 1;
538
+ };
539
+ var basenameOf = (path) => {
540
+ const end = path.length - 1;
541
+ const index = path.lastIndexOf(
542
+ SLASH,
543
+ path[end] === SLASH ? end - 1 : end
544
+ );
545
+ return index < 0 ? path : path.slice(index + 1);
546
+ };
547
+ var parentOf = (path) => {
548
+ if (path.charCodeAt(0) === SLASH_CODE || path.indexOf(DOUBLE_SLASH) >= 0) {
549
+ const slices = path.split(SLASH).filter(Boolean);
550
+ slices.pop();
551
+ return slices.length ? slices.join(SLASH) + SLASH : EMPTY;
552
+ }
553
+ const end = path.length - 1;
554
+ const cut = path.lastIndexOf(
555
+ SLASH,
556
+ path.charCodeAt(end) === SLASH_CODE ? end - 1 : end
557
+ );
558
+ return cut < 0 ? EMPTY : path.slice(0, cut + 1);
245
559
  };
246
- var makeRegexPrefix = (pattern) => REPLACERS.reduce(
247
- (prev, [matcher, replacer]) => prev.replace(matcher, replacer.bind(pattern)),
248
- pattern
249
- );
250
560
  var isString = (subject) => typeof subject === "string";
251
- var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_TEST_BLANK_LINE.test(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern) && pattern.indexOf("#") !== 0;
561
+ var checkPattern = (pattern) => pattern && isString(pattern) && !REGEX_INVALID_TRAILING_BACKSLASH.test(pattern);
252
562
  var splitPattern = (pattern) => pattern.split(REGEX_SPLITALL_CRLF).filter(Boolean);
253
563
  var IgnoreRule = class {
254
564
  constructor(pattern, mark, body2, ignoreCase, negative, prefix) {
@@ -259,6 +569,14 @@ var require_ignore = __commonJS({
259
569
  define(this, "ignoreCase", ignoreCase);
260
570
  define(this, "regexPrefix", prefix);
261
571
  }
572
+ // Worked out on first use and kept behind an own property, the way `regex`
573
+ // caches itself in `_regex`. Deciding it in the constructor instead would
574
+ // add a fourth `defineProperty` to every rule ever built, which cost 4% of
575
+ // every compile -- including the compiles of rules that are never matched
576
+ // against anything.
577
+ get _basenameOnly() {
578
+ return define(this, "_basenameOnly", matchesBasename(this.body));
579
+ }
262
580
  get regex() {
263
581
  const key = UNDERSCORE + MODE_IGNORE;
264
582
  if (this[key]) {
@@ -274,24 +592,51 @@ var require_ignore = __commonJS({
274
592
  return this._make(MODE_CHECK_IGNORE, key);
275
593
  }
276
594
  _make(mode, key) {
277
- const str = this.regexPrefix.replace(
278
- REGEX_REPLACE_TRAILING_WILDCARD,
279
- // It does not need to bind pattern
280
- TRAILING_WILD_CARD_REPLACERS[mode]
595
+ const str = pinWildcards(
596
+ mode === MODE_IGNORE ? this.regexPrefix.replace(REGEX_REPLACE_TRAILING_WILDCARD, replaceTrailingWildcard).replace(REGEX_REPLACE_TRAILING_DOUBLESTAR, replaceTrailingDoublestar) : checkSourceOf(this.body, this.regexPrefix)
281
597
  );
282
598
  const regex = this.ignoreCase ? new RegExp(str, "i") : new RegExp(str);
283
599
  return define(this, key, regex);
284
600
  }
285
601
  };
602
+ var isLineEnd = (char) => char === "\r" || char === "\n";
603
+ var trimEnd = (body2) => {
604
+ let end = body2.length;
605
+ while (end && isLineEnd(body2[end - 1])) {
606
+ end--;
607
+ }
608
+ const lineEnd = end;
609
+ while (end && body2[end - 1] === SPACE) {
610
+ end--;
611
+ }
612
+ if (end === lineEnd) {
613
+ return body2.slice(0, end);
614
+ }
615
+ let backslashes = 0;
616
+ while (backslashes < end && body2[end - backslashes - 1] === ESCAPE) {
617
+ backslashes++;
618
+ }
619
+ return backslashes % 2 ? body2.slice(0, end - 1) + SPACE : body2.slice(0, end);
620
+ };
286
621
  var createRule = ({
287
622
  pattern,
288
623
  mark
289
624
  }, ignoreCase) => {
625
+ let body2 = pattern[0] === BOM ? pattern.slice(1) : pattern;
626
+ if (body2[0] === "#") {
627
+ return;
628
+ }
290
629
  let negative = false;
291
- let body2 = pattern;
292
- if (body2.indexOf("!") === 0) {
630
+ if (body2[0] === "!") {
293
631
  negative = true;
294
- body2 = body2.substr(1);
632
+ body2 = body2.slice(1);
633
+ }
634
+ const last = body2[body2.length - 1];
635
+ if (last === SPACE || last === "\r" || last === "\n") {
636
+ body2 = trimEnd(body2);
637
+ }
638
+ if (!body2) {
639
+ return;
295
640
  }
296
641
  body2 = body2.replace(REGEX_REPLACE_LEADING_EXCAPED_EXCLAMATION, "!").replace(REGEX_REPLACE_LEADING_EXCAPED_HASH, "#");
297
642
  const regexPrefix = makeRegexPrefix(body2);
@@ -308,10 +653,12 @@ var require_ignore = __commonJS({
308
653
  constructor(ignoreCase) {
309
654
  this._ignoreCase = ignoreCase;
310
655
  this._rules = [];
656
+ this._basenameCount = 0;
311
657
  }
312
658
  _add(pattern) {
313
659
  if (pattern && pattern[KEY_IGNORE]) {
314
660
  this._rules = this._rules.concat(pattern._rules._rules);
661
+ this._basenameCount += pattern._rules._basenameCount;
315
662
  this._added = true;
316
663
  return;
317
664
  }
@@ -320,10 +667,13 @@ var require_ignore = __commonJS({
320
667
  pattern
321
668
  };
322
669
  }
323
- if (checkPattern(pattern.pattern)) {
324
- const rule = createRule(pattern, this._ignoreCase);
670
+ const rule = checkPattern(pattern.pattern) && createRule(pattern, this._ignoreCase);
671
+ if (rule) {
325
672
  this._added = true;
326
673
  this._rules.push(rule);
674
+ if (matchesBasename(rule.body)) {
675
+ this._basenameCount++;
676
+ }
327
677
  }
328
678
  }
329
679
  // @param {Array<string> | string | Ignore} pattern
@@ -332,8 +682,39 @@ var require_ignore = __commonJS({
332
682
  makeArray(
333
683
  isString(pattern) ? splitPattern(pattern) : pattern
334
684
  ).forEach(this._add, this);
685
+ if (this._added) {
686
+ this._literalRules = UNDEFINED;
687
+ }
335
688
  return this._added;
336
689
  }
690
+ // Match the literal 'abc/' for `checkIgnore`, last rule wins. Only a rule
691
+ // ending in a wildcard can match it (see `checkSourceOf`), so the rest
692
+ // are left out once, rather than tested or compiled for every path.
693
+ testLiteral(path) {
694
+ const rules = this._literalRules || (this._literalRules = this._rules.filter(
695
+ ({ body: body2 }) => body2[body2.length - (body2[body2.length - 1] === SLASH ? 2 : 1)] === "*"
696
+ ));
697
+ let ignored = false;
698
+ let unignored = false;
699
+ let matchedRule;
700
+ for (let index = rules.length - 1; index >= 0; index--) {
701
+ const rule = rules[index];
702
+ if (rule.checkRegex.test(path)) {
703
+ ignored = !rule.negative;
704
+ unignored = rule.negative;
705
+ matchedRule = rule.negative ? UNDEFINED : rule;
706
+ break;
707
+ }
708
+ }
709
+ const ret = {
710
+ ignored,
711
+ unignored
712
+ };
713
+ if (matchedRule) {
714
+ ret.rule = matchedRule;
715
+ }
716
+ return ret;
717
+ }
337
718
  // Test one single path without recursively checking parent directories
338
719
  //
339
720
  // - checkUnignored `boolean` whether should check if the path is unignored,
@@ -345,19 +726,22 @@ var require_ignore = __commonJS({
345
726
  let ignored = false;
346
727
  let unignored = false;
347
728
  let matchedRule;
348
- this._rules.forEach((rule) => {
729
+ const rules = this._rules;
730
+ const { length } = rules;
731
+ const shortcut = this._basenameCount * 2 >= length;
732
+ const basename4 = shortcut ? basenameOf(path) : path;
733
+ for (let index = 0; index < length; index++) {
734
+ const rule = rules[index];
349
735
  const { negative } = rule;
350
- if (unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored) {
351
- return;
736
+ const skip = unignored === negative && ignored !== unignored || negative && !ignored && !unignored && !checkUnignored;
737
+ if (!skip && rule[mode].test(
738
+ shortcut && rule._basenameOnly ? basename4 : path
739
+ )) {
740
+ ignored = !negative;
741
+ unignored = negative;
742
+ matchedRule = negative ? UNDEFINED : rule;
352
743
  }
353
- const matched = rule[mode].test(path);
354
- if (!matched) {
355
- return;
356
- }
357
- ignored = !negative;
358
- unignored = negative;
359
- matchedRule = negative ? UNDEFINED : rule;
360
- });
744
+ }
361
745
  const ret = {
362
746
  ignored,
363
747
  unignored
@@ -390,7 +774,26 @@ var require_ignore = __commonJS({
390
774
  }
391
775
  return true;
392
776
  };
393
- var isNotRelative = (path) => REGEX_TEST_INVALID_PATH.test(path);
777
+ var isNotRelative = (path) => {
778
+ const first = path.charCodeAt(0);
779
+ if (first === SLASH_CODE) {
780
+ return true;
781
+ }
782
+ if (first !== DOT_CODE) {
783
+ return false;
784
+ }
785
+ if (path.length === 1) {
786
+ return true;
787
+ }
788
+ const second = path.charCodeAt(1);
789
+ if (second === SLASH_CODE) {
790
+ return true;
791
+ }
792
+ if (second !== DOT_CODE) {
793
+ return false;
794
+ }
795
+ return path.length === 2 || path.charCodeAt(2) === SLASH_CODE;
796
+ };
394
797
  checkPath.isNotRelative = isNotRelative;
395
798
  checkPath.convert = (p) => p;
396
799
  var Ignore = class {
@@ -419,52 +822,33 @@ var require_ignore = __commonJS({
419
822
  return this.add(pattern);
420
823
  }
421
824
  // @returns {TestResult}
422
- _test(originalPath, cache, checkUnignored, slices) {
825
+ _test(originalPath, cache, checkUnignored) {
423
826
  const path = originalPath && checkPath.convert(originalPath);
424
827
  checkPath(
425
828
  path,
426
829
  originalPath,
427
830
  this._strictPathCheck ? throwError : RETURN_FALSE
428
831
  );
429
- return this._t(path, cache, checkUnignored, slices);
832
+ return this._t(path, cache, checkUnignored);
430
833
  }
431
834
  checkIgnore(path) {
432
- if (!REGEX_TEST_TRAILING_SLASH.test(path)) {
835
+ if (path.charCodeAt(path.length - 1) !== SLASH_CODE) {
433
836
  return this.test(path);
434
837
  }
435
- const slices = path.split(SLASH).filter(Boolean);
436
- slices.pop();
437
- if (slices.length) {
438
- const parent = this._t(
439
- slices.join(SLASH) + SLASH,
440
- this._testCache,
441
- true,
442
- slices
443
- );
444
- if (parent.ignored) {
445
- return parent;
446
- }
838
+ const dir = this._t(path, this._testCache, true);
839
+ if (dir.ignored) {
840
+ return dir;
447
841
  }
448
- return this._rules.test(path, false, MODE_CHECK_IGNORE);
842
+ const literal = this._rules.testLiteral(path);
843
+ return literal.ignored || literal.unignored ? literal : dir;
449
844
  }
450
- _t(path, cache, checkUnignored, slices) {
845
+ _t(path, cache, checkUnignored) {
451
846
  if (path in cache) {
452
847
  return cache[path];
453
848
  }
454
- if (!slices) {
455
- slices = path.split(SLASH).filter(Boolean);
456
- }
457
- slices.pop();
458
- if (!slices.length) {
459
- return cache[path] = this._rules.test(path, checkUnignored, MODE_IGNORE);
460
- }
461
- const parent = this._t(
462
- slices.join(SLASH) + SLASH,
463
- cache,
464
- checkUnignored,
465
- slices
466
- );
467
- return cache[path] = parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
849
+ const parentPath = parentOf(path);
850
+ const parent = parentPath ? this._t(parentPath, cache, checkUnignored) : UNDEFINED;
851
+ return cache[path] = parent && parent.ignored ? parent : this._rules.test(path, checkUnignored, MODE_IGNORE);
468
852
  }
469
853
  ignores(path) {
470
854
  return this._test(path, this._ignoreCache, false).ignored;
@@ -2855,6 +3239,18 @@ function setModule(module2) {
2855
3239
  }
2856
3240
  __name(setModule, "setModule");
2857
3241
  var C;
3242
+ function newFinalizer(handler) {
3243
+ try {
3244
+ return new FinalizationRegistry(handler);
3245
+ } catch (e) {
3246
+ console.error("Unsupported FinalizationRegistry:", e);
3247
+ return;
3248
+ }
3249
+ }
3250
+ __name(newFinalizer, "newFinalizer");
3251
+ var finalizer = newFinalizer((address) => {
3252
+ C._ts_lookahead_iterator_delete(address);
3253
+ });
2858
3254
  var LookaheadIterator = class {
2859
3255
  static {
2860
3256
  __name(this, "LookaheadIterator");
@@ -2865,21 +3261,39 @@ var LookaheadIterator = class {
2865
3261
  /** @internal */
2866
3262
  language;
2867
3263
  /** @internal */
3264
+ positioned = false;
3265
+ /** @internal */
2868
3266
  constructor(internal, address, language) {
2869
3267
  assertInternal(internal);
2870
3268
  this[0] = address;
2871
3269
  this.language = language;
3270
+ finalizer?.register(this, address, this);
2872
3271
  }
2873
- /** Get the current symbol of the lookahead iterator. */
3272
+ /**
3273
+ * Get the current symbol of the lookahead iterator.
3274
+ *
3275
+ * Returns `null` if the iterator is not positioned on a symbol:
3276
+ *
3277
+ * - Before the first iteration step
3278
+ * - After the iterator is exhausted
3279
+ * - After a {@link reset} or {@link resetState} call
3280
+ */
2874
3281
  get currentTypeId() {
2875
- return C._ts_lookahead_iterator_current_symbol(this[0]);
3282
+ return this.positioned ? C._ts_lookahead_iterator_current_symbol(this[0]) : null;
2876
3283
  }
2877
- /** Get the current symbol name of the lookahead iterator. */
3284
+ /**
3285
+ * Get the current symbol name of the lookahead iterator.
3286
+ *
3287
+ * Returns `null` if the iterator is not positioned on a symbol.
3288
+ */
2878
3289
  get currentType() {
2879
- return this.language.types[this.currentTypeId] || "ERROR";
3290
+ const id = this.currentTypeId;
3291
+ if (id === null) return null;
3292
+ return this.language.types[id] ?? C.UTF8ToString(C._ts_language_symbol_name(this.language[0], id));
2880
3293
  }
2881
3294
  /** Delete the lookahead iterator, freeing its resources. */
2882
3295
  delete() {
3296
+ finalizer?.unregister(this);
2883
3297
  C._ts_lookahead_iterator_delete(this[0]);
2884
3298
  this[0] = 0;
2885
3299
  }
@@ -2892,6 +3306,7 @@ var LookaheadIterator = class {
2892
3306
  reset(language, stateId) {
2893
3307
  if (C._ts_lookahead_iterator_reset(this[0], language[0], stateId)) {
2894
3308
  this.language = language;
3309
+ this.positioned = false;
2895
3310
  return true;
2896
3311
  }
2897
3312
  return false;
@@ -2903,7 +3318,9 @@ var LookaheadIterator = class {
2903
3318
  * `false` otherwise.
2904
3319
  */
2905
3320
  resetState(stateId) {
2906
- return Boolean(C._ts_lookahead_iterator_reset_state(this[0], stateId));
3321
+ if (!C._ts_lookahead_iterator_reset_state(this[0], stateId)) return false;
3322
+ this.positioned = false;
3323
+ return true;
2907
3324
  }
2908
3325
  /**
2909
3326
  * Returns an iterator that iterates over the symbols of the lookahead iterator.
@@ -2914,10 +3331,9 @@ var LookaheadIterator = class {
2914
3331
  [Symbol.iterator]() {
2915
3332
  return {
2916
3333
  next: /* @__PURE__ */ __name(() => {
2917
- if (C._ts_lookahead_iterator_next(this[0])) {
2918
- return { done: false, value: this.currentType };
2919
- }
2920
- return { done: true, value: "" };
3334
+ this.positioned = Boolean(C._ts_lookahead_iterator_next(this[0]));
3335
+ const value = this.currentType;
3336
+ return value === null ? { done: true, value: "" } : { done: false, value };
2921
3337
  }, "next")
2922
3338
  };
2923
3339
  }
@@ -2943,6 +3359,9 @@ function getText(tree, startIndex, endIndex, startPosition) {
2943
3359
  return result ?? "";
2944
3360
  }
2945
3361
  __name(getText, "getText");
3362
+ var finalizer2 = newFinalizer((address) => {
3363
+ C._ts_tree_delete(address);
3364
+ });
2946
3365
  var Tree = class _Tree {
2947
3366
  static {
2948
3367
  __name(this, "Tree");
@@ -2960,6 +3379,7 @@ var Tree = class _Tree {
2960
3379
  this[0] = address;
2961
3380
  this.language = language;
2962
3381
  this.textCallback = textCallback;
3382
+ finalizer2?.register(this, address, this);
2963
3383
  }
2964
3384
  /** Create a shallow copy of the syntax tree. This is very fast. */
2965
3385
  copy() {
@@ -2968,6 +3388,7 @@ var Tree = class _Tree {
2968
3388
  }
2969
3389
  /** Delete the syntax tree, freeing its resources. */
2970
3390
  delete() {
3391
+ finalizer2?.unregister(this);
2971
3392
  C._ts_tree_delete(this[0]);
2972
3393
  this[0] = 0;
2973
3394
  }
@@ -3048,6 +3469,9 @@ var Tree = class _Tree {
3048
3469
  return result;
3049
3470
  }
3050
3471
  };
3472
+ var finalizer3 = newFinalizer((address) => {
3473
+ C._ts_tree_cursor_delete_wasm(address);
3474
+ });
3051
3475
  var TreeCursor = class _TreeCursor {
3052
3476
  static {
3053
3477
  __name(this, "TreeCursor");
@@ -3075,6 +3499,7 @@ var TreeCursor = class _TreeCursor {
3075
3499
  assertInternal(internal);
3076
3500
  this.tree = tree;
3077
3501
  unmarshalTreeCursor(this);
3502
+ finalizer3?.register(this, this.tree[0], this);
3078
3503
  }
3079
3504
  /** Creates a deep copy of the tree cursor. This allocates new memory. */
3080
3505
  copy() {
@@ -3085,6 +3510,7 @@ var TreeCursor = class _TreeCursor {
3085
3510
  }
3086
3511
  /** Delete the tree cursor, freeing its resources. */
3087
3512
  delete() {
3513
+ finalizer3?.unregister(this);
3088
3514
  marshalTreeCursor(this);
3089
3515
  C._ts_tree_cursor_delete_wasm(this.tree[0]);
3090
3516
  this[0] = this[1] = this[2] = 0;
@@ -4179,8 +4605,9 @@ var Language = class _Language {
4179
4605
  * This returns `null` if state is invalid for this language.
4180
4606
  *
4181
4607
  * Iterating {@link LookaheadIterator} will yield valid symbols in the given
4182
- * parse state. Newly created lookahead iterators will return the `ERROR`
4183
- * symbol from {@link LookaheadIterator#currentType}.
4608
+ * parse state. A newly created iterator is not positioned on a symbol, so
4609
+ * {@link LookaheadIterator#currentType} returns `null` until the first
4610
+ * iteration step.
4184
4611
  *
4185
4612
  * Lookahead iterators can be useful for generating suggestions and improving
4186
4613
  * syntax error diagnostics. To get symbols valid in an `ERROR` node, use the
@@ -4195,7 +4622,8 @@ var Language = class _Language {
4195
4622
  }
4196
4623
  /**
4197
4624
  * Load a language from a WebAssembly module.
4198
- * The module can be provided as a path to a file or as a buffer.
4625
+ * The module can be provided as a path to a file, a `URL` to a file, or as a
4626
+ * buffer.
4199
4627
  */
4200
4628
  static async load(input) {
4201
4629
  let binary2;
@@ -4222,16 +4650,27 @@ ${body2}`);
4222
4650
  }
4223
4651
  }
4224
4652
  const mod = await C.loadWebAssemblyModule(binary2, { loadAsync: true });
4653
+ return _Language.loadFromWasmExports(mod, { sync: false });
4654
+ }
4655
+ static loadFromWasmExports(mod, { sync }) {
4225
4656
  const symbolNames = Object.keys(mod);
4226
4657
  const functionName = symbolNames.find((key) => LANGUAGE_FUNCTION_REGEX.test(key) && !key.includes("external_scanner_"));
4227
4658
  if (!functionName) {
4228
4659
  console.log(`Couldn't find language function in Wasm file. Symbols:
4229
4660
  ${JSON.stringify(symbolNames, null, 2)}`);
4230
- throw new Error("Language.load failed: no language function found in Wasm file");
4661
+ throw new Error(`Language.${sync ? "loadSync" : "load"} failed: no language function found in Wasm file`);
4231
4662
  }
4232
4663
  const languageAddress = mod[functionName]();
4233
4664
  return new _Language(INTERNAL, languageAddress);
4234
4665
  }
4666
+ /**
4667
+ * Load a language synchronously from a pre-compiled WebAssembly module.
4668
+ * Use this when the host environment provides a `WebAssembly.Module` directly.
4669
+ */
4670
+ static loadSync(wasmModule) {
4671
+ const mod = C.loadWebAssemblyModule(wasmModule, { loadAsync: false });
4672
+ return _Language.loadFromWasmExports(mod, { sync: true });
4673
+ }
4235
4674
  };
4236
4675
  async function Module2(moduleArg = {}) {
4237
4676
  var moduleRtn;
@@ -4754,7 +5193,7 @@ async function Module2(moduleArg = {}) {
4754
5193
  newDSO("__main__", 0, wasmImports);
4755
5194
  }
4756
5195
  };
4757
- var ___heap_base = 78240;
5196
+ var ___heap_base = 82240;
4758
5197
  var alignMemory = /* @__PURE__ */ __name((size, alignment) => Math.ceil(size / alignment) * alignment, "alignMemory");
4759
5198
  var getMemory = /* @__PURE__ */ __name((size) => {
4760
5199
  if (runtimeInitialized) {
@@ -5319,12 +5758,12 @@ async function Module2(moduleArg = {}) {
5319
5758
  "value": "i32",
5320
5759
  "mutable": false
5321
5760
  }, 1024);
5322
- var ___stack_high = 78240;
5323
- var ___stack_low = 12704;
5761
+ var ___stack_high = 82240;
5762
+ var ___stack_low = 16704;
5324
5763
  var ___stack_pointer = new WebAssembly.Global({
5325
5764
  "value": "i32",
5326
5765
  "mutable": true
5327
- }, 78240);
5766
+ }, 82240);
5328
5767
  var ___table_base = new WebAssembly.Global({
5329
5768
  "value": "i32",
5330
5769
  "mutable": false
@@ -5585,7 +6024,7 @@ async function Module2(moduleArg = {}) {
5585
6024
  Module["loadWebAssemblyModule"] = loadWebAssemblyModule;
5586
6025
  Module["LE_HEAP_STORE_I64"] = LE_HEAP_STORE_I64;
5587
6026
  var ASM_CONSTS = {};
5588
- 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;
6027
+ 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;
5589
6028
  function assignWasmExports(wasmExports2) {
5590
6029
  Module["_malloc"] = _malloc = wasmExports2["malloc"];
5591
6030
  Module["_calloc"] = _calloc = wasmExports2["calloc"];
@@ -5619,6 +6058,7 @@ async function Module2(moduleArg = {}) {
5619
6058
  Module["_ts_query_delete"] = _ts_query_delete = wasmExports2["ts_query_delete"];
5620
6059
  Module["_iswspace"] = _iswspace = wasmExports2["iswspace"];
5621
6060
  Module["_iswalnum"] = _iswalnum = wasmExports2["iswalnum"];
6061
+ Module["_ts_query_copy"] = _ts_query_copy = wasmExports2["ts_query_copy"];
5622
6062
  Module["_ts_query_pattern_count"] = _ts_query_pattern_count = wasmExports2["ts_query_pattern_count"];
5623
6063
  Module["_ts_query_capture_count"] = _ts_query_capture_count = wasmExports2["ts_query_capture_count"];
5624
6064
  Module["_ts_query_string_count"] = _ts_query_string_count = wasmExports2["ts_query_string_count"];
@@ -5724,6 +6164,7 @@ async function Module2(moduleArg = {}) {
5724
6164
  Module["_iswblank"] = _iswblank = wasmExports2["iswblank"];
5725
6165
  Module["_iswdigit"] = _iswdigit = wasmExports2["iswdigit"];
5726
6166
  Module["_iswlower"] = _iswlower = wasmExports2["iswlower"];
6167
+ Module["_iswpunct"] = _iswpunct = wasmExports2["iswpunct"];
5727
6168
  Module["_iswupper"] = _iswupper = wasmExports2["iswupper"];
5728
6169
  Module["_iswxdigit"] = _iswxdigit = wasmExports2["iswxdigit"];
5729
6170
  Module["_memchr"] = _memchr = wasmExports2["memchr"];
@@ -5861,6 +6302,10 @@ __name(checkModule, "checkModule");
5861
6302
  var TRANSFER_BUFFER;
5862
6303
  var LANGUAGE_VERSION;
5863
6304
  var MIN_COMPATIBLE_VERSION;
6305
+ var finalizer4 = newFinalizer((addresses) => {
6306
+ C._ts_parser_delete(addresses[0]);
6307
+ C._free(addresses[1]);
6308
+ });
5864
6309
  var Parser = class {
5865
6310
  static {
5866
6311
  __name(this, "Parser");
@@ -5892,6 +6337,7 @@ var Parser = class {
5892
6337
  */
5893
6338
  constructor() {
5894
6339
  this.initialize();
6340
+ finalizer4?.register(this, [this[0], this[1]], this);
5895
6341
  }
5896
6342
  /** @internal */
5897
6343
  initialize() {
@@ -5904,6 +6350,7 @@ var Parser = class {
5904
6350
  }
5905
6351
  /** Delete the parser, freeing its resources. */
5906
6352
  delete() {
6353
+ finalizer4?.unregister(this);
5907
6354
  C._ts_parser_delete(this[0]);
5908
6355
  C._free(this[1]);
5909
6356
  this[0] = 0;
@@ -6079,6 +6526,10 @@ var QueryError = class _QueryError extends Error {
6079
6526
  this.length = length;
6080
6527
  this.name = "QueryError";
6081
6528
  }
6529
+ kind;
6530
+ info;
6531
+ index;
6532
+ length;
6082
6533
  static {
6083
6534
  __name(this, "QueryError");
6084
6535
  }
@@ -6274,6 +6725,9 @@ function parsePattern(index, stepType, stepValueId, captureNames, stringValues,
6274
6725
  }
6275
6726
  }
6276
6727
  __name(parsePattern, "parsePattern");
6728
+ var finalizer5 = newFinalizer((address) => {
6729
+ C._ts_query_delete(address);
6730
+ });
6277
6731
  var Query = class {
6278
6732
  static {
6279
6733
  __name(this, "Query");
@@ -6428,9 +6882,11 @@ var Query = class {
6428
6882
  this.assertedProperties = assertedProperties;
6429
6883
  this.refutedProperties = refutedProperties;
6430
6884
  this.exceededMatchLimit = false;
6885
+ finalizer5?.register(this, address, this);
6431
6886
  }
6432
6887
  /** Delete the query, freeing its resources. */
6433
6888
  delete() {
6889
+ finalizer5?.unregister(this);
6434
6890
  C._ts_query_delete(this[0]);
6435
6891
  this[0] = 0;
6436
6892
  }