#!/usr/bin/env node /** * Disable @xterm/addon-webgl's cross-terminal texture-atlas sharing. * * xterm's WebGL addon shares ONE TextureAtlas across terminal instances whose * config (font / size / theme / device-pixel-ratio) is equal — see * `acquireTextureAtlas`, which does `if (configEquals) { ownedBy.push; return * atlas }`. In a split workspace two panes then share an atlas, so clearing or * rebuilding it for one pane (which netcatty does on resize / DPR change / font * change / tab show to recover from glyph corruption) corrupts the OTHER pane's * rendering — the persistent "花屏 / garbled" report in issue #1063, most * visible in split view where both panes stay on screen. * * Fix: give every terminal its own atlas by removing the "reuse a matching * atlas" loop, so each terminal falls through to creating its own. The published * package is minified, so we string-replace the exact loop in both the CJS and * ESM builds. This runs from `postinstall` (after patch-package). * * Idempotent. If the upstream code changes (e.g. an @xterm/addon-webgl upgrade) * the loop won't be found; we warn loudly but do not fail the install, and the * strings below must then be refreshed for the new version. */ "use strict"; const fs = require("node:fs"); const path = require("node:path"); const MARKER = "/*netcatty:#1063 atlas-isolation*/"; // Exact (minified) "reuse a shared atlas" loop, per @xterm/addon-webgl@0.19.0. const TARGETS = [ { file: "node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs", loop: "for(let h=0;h