Files
SenMeshNet/scripts/patch-xterm-webgl-atlas.cjs
zhaolei 2f9f8da48e
Some checks failed
AI automation / Route event (push) Has been cancelled
AI automation / Hand reopened issue to maintainers (push) Has been cancelled
AI automation / Clean source issue state (push) Has been cancelled
AI automation / Reconcile handoffs (push) Has been cancelled
AI automation / Classify issue (push) Has been cancelled
AI automation / Claude Code smoke (push) Has been cancelled
AI automation / Review issue follow-up (push) Has been cancelled
AI automation / Publish issue follow-up (push) Has been cancelled
AI automation / Implement with Claude Code (push) Has been cancelled
AI automation / Publish implement PR (push) Has been cancelled
AI automation / Continue queued issue comments (push) Has been cancelled
AI automation / Codex review loop (push) Has been cancelled
AI automation / Publish Codex fix (push) Has been cancelled
AI automation / Clear Codex dispatch marker (push) Has been cancelled
AI automation / Own PR re-request Codex (push) Has been cancelled
AI automation / External PR re-request Codex (push) Has been cancelled
AI automation / Poll Codex reaction / retry (push) Has been cancelled
Initial commit: NetMesh smart ops platform with 3D topology, inspection reports, RCA and AI ops assistant
2026-10-15 13:53:04 +08:00

108 lines
3.2 KiB
JavaScript

#!/usr/bin/env node
/* global process, console */
/**
* Verify @xterm/addon-webgl carries the upstream glyph-atlas safety fixes.
*
* Netcatty previously backported these as local string patches. With
* @xterm/addon-webgl >= 0.20.0-beta.291 they ship upstream:
*
* - xtermjs/xterm.js#6055 — shared atlas: clearTexture bumps _pageLayoutVersion
* - xtermjs/xterm.js#5987 — no generateMipmap on atlas upload (LINEAR filters)
* - xtermjs/xterm.js#6043 — _evictAllPages / maxAtlasPages capacity handling
*
* This script no longer mutates node_modules. It only fails closed when the
* pinned package is missing any of the above, so a silent downgrade cannot
* reintroduce garbled split-pane / mipmap / overflow bugs.
*/
"use strict";
const fs = require("node:fs");
const path = require("node:path");
const TARGET_FILES = [
"node_modules/@xterm/addon-webgl/lib/addon-webgl.mjs",
"node_modules/@xterm/addon-webgl/lib/addon-webgl.js",
];
/** Upstream #6055: clearTexture bumps page layout version so shared atlases rebuild. */
function hasUpstreamSharedAtlasClearFix(source) {
return (
source.includes("_pageLayoutVersion") &&
/clearTexture\(\)\{[^}]*_pageLayoutVersion\+\+/.test(source)
);
}
/** Upstream #5987: atlas texture upload must not call generateMipmap. */
function hasUpstreamMipmapFix(source) {
return !source.includes(".generateMipmap(");
}
/** Upstream #6043: capacity eviction when atlas pages overflow texture slots. */
function hasUpstreamCapacityFix(source) {
return source.includes("_evictAllPages()") && source.includes("maxAtlasPages");
}
let webglVersion = "";
try {
const packageJson = path.resolve(
process.cwd(),
"node_modules/@xterm/addon-webgl/package.json",
);
webglVersion = JSON.parse(fs.readFileSync(packageJson, "utf8")).version || "";
} catch {
// Handled below when files are missing.
}
const results = { ok: 0, missing: 0 };
for (const file of TARGET_FILES) {
const abs = path.resolve(process.cwd(), file);
let source;
try {
source = fs.readFileSync(abs, "utf8");
} catch {
console.warn(`[patch-xterm-webgl-atlas] ERROR: not found: ${file}`);
results.missing++;
continue;
}
const checks = [
{
name: "shared-atlas clear (#6055)",
ok: hasUpstreamSharedAtlasClearFix(source),
hint: "need clearTexture() { ... _pageLayoutVersion++ }",
},
{
name: "no atlas mipmaps (#5987)",
ok: hasUpstreamMipmapFix(source),
hint: "must not call gl.generateMipmap on atlas upload",
},
{
name: "atlas capacity eviction (#6043)",
ok: hasUpstreamCapacityFix(source),
hint: "need _evictAllPages() and maxAtlasPages",
},
];
const failed = checks.filter((check) => !check.ok);
if (failed.length === 0) {
results.ok++;
continue;
}
results.missing++;
for (const check of failed) {
console.warn(
`[patch-xterm-webgl-atlas] ERROR: missing ${check.name} in ${file} ` +
`(${check.hint}). Upgrade @xterm/addon-webgl ` +
`(current: ${webglVersion || "unknown"}).`,
);
}
}
console.log(
`[patch-xterm-webgl-atlas] verify version=${webglVersion || "unknown"} ` +
`ok=${results.ok} missing=${results.missing}`,
);
if (results.missing > 0) process.exitCode = 1;