- Add C WASM scanner emitting structure-of-arrays ops (kinds, starts, lengths, aux, params) - Integrate scan+dispatch in EscapeSequenceParser with async handler resume - Fix CSI fast-path final byte index, ERROR state reporting, and precedingJoinState for REP - Add build pipeline (build_parser_wasm.sh, transition table generator, wasm embed) Co-authored-by: Daniel Imms <Tyriar@users.noreply.github.com>
35 lines
1.2 KiB
JavaScript
35 lines
1.2 KiB
JavaScript
/**
|
|
* Copyright (c) 2026 The xterm.js authors. All rights reserved.
|
|
* @license MIT
|
|
*/
|
|
|
|
// @ts-check
|
|
import { writeFileSync } from 'fs';
|
|
import { fileURLToPath } from 'url';
|
|
import { dirname, join } from 'path';
|
|
|
|
const __dirname = dirname(fileURLToPath(import.meta.url));
|
|
const root = join(__dirname, '..');
|
|
|
|
// Import compiled transition table
|
|
const { VT500_TRANSITION_TABLE } = await import(join(root, 'out/common/parser/EscapeSequenceParser.js'));
|
|
|
|
const table = VT500_TRANSITION_TABLE.table;
|
|
let out = '/* Auto-generated by bin/gen_parser_transition_table.mjs - do not edit */\n';
|
|
out += `#ifndef PARSER_TRANSITION_TABLE_H\n#define PARSER_TRANSITION_TABLE_H\n\n`;
|
|
out += `#include <stdint.h>\n\n`;
|
|
out += `#define PARSER_TABLE_SIZE ${table.length}\n\n`;
|
|
out += `static const uint16_t PARSER_TRANSITION_TABLE[PARSER_TABLE_SIZE] = {\n`;
|
|
for (let i = 0; i < table.length; i++) {
|
|
if (i % 16 === 0) out += ' ';
|
|
out += `0x${table[i].toString(16)}`;
|
|
out += i < table.length - 1 ? ', ' : '';
|
|
if (i % 16 === 15) out += '\n';
|
|
}
|
|
if (table.length % 16 !== 0) out += '\n';
|
|
out += `};\n\n#endif\n`;
|
|
|
|
const headerPath = join(root, 'src/common/parser/wasm/transition_table.h');
|
|
writeFileSync(headerPath, out);
|
|
console.info(`Wrote ${headerPath} (${table.length} entries)`);
|