@mnemonik/shared 7.145.0 → 7.145.1
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/package.json +1 -1
- package/scripts/vendor-grammars.ts +36 -1
- package/wasm/javascript.wasm.gz +0 -0
- package/wasm/tsx.wasm.gz +0 -0
- package/wasm/typescript.wasm.gz +0 -0
package/package.json
CHANGED
|
@@ -383,7 +383,7 @@ function rebuildTypescript(dir: string, work: string, only?: string): void {
|
|
|
383
383
|
],
|
|
384
384
|
[
|
|
385
385
|
" field('type_arguments', optional($.type_arguments)),\n field('arguments', $.arguments),",
|
|
386
|
-
" field('type_arguments', optional($.type_arguments)),\n field('arguments', choice($.arguments, $.template_string)),",
|
|
386
|
+
" field('type_arguments', optional($.type_arguments)),\n field('arguments', choice($.arguments, alias($._tagged_template_string, $.template_string))),",
|
|
387
387
|
],
|
|
388
388
|
[
|
|
389
389
|
" type_parameter: $ => seq(\n optional('const'),\n field('name', $._type_identifier),",
|
|
@@ -441,6 +441,10 @@ function rebuildTypescript(dir: string, work: string, only?: string): void {
|
|
|
441
441
|
optional(seq('as', field('alias', $._module_export_name))),
|
|
442
442
|
),`
|
|
443
443
|
);
|
|
444
|
+
grammar = grammar.replaceAll(
|
|
445
|
+
"field('arguments', $.template_string)",
|
|
446
|
+
"field('arguments', alias($._tagged_template_string, $.template_string))"
|
|
447
|
+
);
|
|
444
448
|
writeFileSync(grammarPath, grammar);
|
|
445
449
|
const scannerPath = join(dir, 'common', 'scanner.h');
|
|
446
450
|
let scanner = readFileSync(scannerPath, 'utf8');
|
|
@@ -481,6 +485,8 @@ function rebuildTypescript(dir: string, work: string, only?: string): void {
|
|
|
481
485
|
'tree-sitter-javascript@0.23.1',
|
|
482
486
|
]);
|
|
483
487
|
const cli = join(tools, 'node_modules', '.bin', 'tree-sitter');
|
|
488
|
+
// CLI 0.24 mis-emits the complementary character class; spell out raw characters.
|
|
489
|
+
patchTaggedTemplates(join(tools, 'node_modules', 'tree-sitter-javascript', 'grammar.js'), false);
|
|
484
490
|
for (const dialect of ['typescript', 'tsx']) {
|
|
485
491
|
if (only && !only.split(',').includes(dialect)) continue;
|
|
486
492
|
// Apply the JSX scanner and attribute repairs only to TSX.
|
|
@@ -502,6 +508,34 @@ function rebuildTypescript(dir: string, work: string, only?: string): void {
|
|
|
502
508
|
}
|
|
503
509
|
}
|
|
504
510
|
|
|
511
|
+
/** Tagged templates retain invalid escape spellings as raw text; ordinary literals stay strict. */
|
|
512
|
+
function patchTaggedTemplates(grammarPath: string, complementaryClass = true): void {
|
|
513
|
+
let grammar = readFileSync(grammarPath, 'utf8');
|
|
514
|
+
const argument = "field('arguments', $.template_string)";
|
|
515
|
+
const template = ' template_string: $ => seq(';
|
|
516
|
+
if (!grammar.includes(argument) || !grammar.includes(template))
|
|
517
|
+
throw new Error('Tagged-template escape patch no longer applies');
|
|
518
|
+
const tagged = [
|
|
519
|
+
' _tagged_template_string: $ => seq(',
|
|
520
|
+
" '`',",
|
|
521
|
+
' repeat(choice(',
|
|
522
|
+
' alias($._template_chars, $.string_fragment),',
|
|
523
|
+
' $.escape_sequence,',
|
|
524
|
+
complementaryClass
|
|
525
|
+
? " alias(token.immediate(prec(1, seq('\\\\', /[\\s\\S]/))), $.escape_sequence),"
|
|
526
|
+
: " alias(token.immediate(prec(1, seq('\\\\', choice(/./, /[\\r\\n\\u2028\\u2029]/)))), $.escape_sequence),",
|
|
527
|
+
' $.template_substitution,',
|
|
528
|
+
' )),',
|
|
529
|
+
" '`',",
|
|
530
|
+
' ),',
|
|
531
|
+
'',
|
|
532
|
+
].join('\n');
|
|
533
|
+
grammar = grammar
|
|
534
|
+
.replaceAll(argument, "field('arguments', alias($._tagged_template_string, $.template_string))")
|
|
535
|
+
.replace(template, tagged + template);
|
|
536
|
+
writeFileSync(grammarPath, grammar);
|
|
537
|
+
}
|
|
538
|
+
|
|
505
539
|
/** Upstream f8637eb: preserve entity boundaries while accepting bare JSX ampersands. */
|
|
506
540
|
function patchJsxScanner(scannerPath: string): void {
|
|
507
541
|
execFileSync('patch', ['--batch', scannerPath], {
|
|
@@ -532,6 +566,7 @@ function patchJsxAttributes(grammarPath: string): void {
|
|
|
532
566
|
|
|
533
567
|
/** 0.25.0's reserved-word DSL needs generator 0.25.8; keep the existing WASM build tool. */
|
|
534
568
|
function rebuildJavascript(dir: string, work: string): void {
|
|
569
|
+
patchTaggedTemplates(join(dir, 'grammar.js'));
|
|
535
570
|
patchJsxScanner(join(dir, 'src', 'scanner.c'));
|
|
536
571
|
patchJsxAttributes(join(dir, 'grammar.js'));
|
|
537
572
|
const generator = join(work, 'javascript-generator');
|
package/wasm/javascript.wasm.gz
CHANGED
|
Binary file
|
package/wasm/tsx.wasm.gz
CHANGED
|
Binary file
|
package/wasm/typescript.wasm.gz
CHANGED
|
Binary file
|