@opencrater/sdk 0.8.48 → 0.8.49
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.
Potentially problematic release.
This version of @opencrater/sdk might be problematic. Click here for more details.
- package/dist/paint.js +43 -4
- package/package.json +1 -1
package/dist/paint.js
CHANGED
|
@@ -308,6 +308,12 @@ var WIN_PUMP_PS = [
|
|
|
308
308
|
"$h=OpenConout",
|
|
309
309
|
"if($h -eq [IntPtr]-1){ L 'pump: NO CONSOLE after attach walk'; exit 1 }",
|
|
310
310
|
"$fb=Csbi $h; if($fb){ L ('pump: FINAL via '+$how+' bufH='+$fb.sz.Y+' winRows='+($fb.win.B-$fb.win.T+1)+' curY='+$fb.cur.Y) } else { L ('pump: FINAL via '+$how) }",
|
|
311
|
+
// Report the REAL visible-console size back to the painter (over stdout, a
|
|
312
|
+
// pipe — the card itself goes to CONOUT$ via WriteFile, so this channel is
|
|
313
|
+
// free). The painter blocks on this line, then anchors the card to the true
|
|
314
|
+
// right edge. win.R/L/B/T are the on-screen window rect (not the scrollback
|
|
315
|
+
// buffer), so this is exactly what `mode con` SHOULD have returned.
|
|
316
|
+
"if($fb){ $cols=$fb.win.R-$fb.win.L+1; $rows=$fb.win.B-$fb.win.T+1; [Console]::Out.WriteLine('OCSIZE '+$cols+' '+$rows); [Console]::Out.Flush() }",
|
|
311
317
|
"$m=[uint32]0;[void][OCP.N]::GetConsoleMode($h,[ref]$m);[void][OCP.N]::SetConsoleMode($h,($m -bor 4));[void][OCP.N]::SetConsoleOutputCP(65001)",
|
|
312
318
|
// Stream frames straight to the console as they arrive. The painter drives
|
|
313
319
|
// the timing — it repaints the overlay (live countdown, position defence)
|
|
@@ -337,7 +343,7 @@ function spawnWindowsConsoleSink() {
|
|
|
337
343
|
}
|
|
338
344
|
pdebug("spawning pump:", exe);
|
|
339
345
|
const child = child_process.spawn(exe, ["-NoProfile", "-NonInteractive", "-EncodedCommand", b64], {
|
|
340
|
-
stdio: ["pipe",
|
|
346
|
+
stdio: ["pipe", "pipe", errStdio],
|
|
341
347
|
windowsHide: false
|
|
342
348
|
});
|
|
343
349
|
child.on("error", (e) => pdebug("pump spawn error:", exe, "-", e.message));
|
|
@@ -353,7 +359,32 @@ function spawnWindowsConsoleSink() {
|
|
|
353
359
|
child.on("exit", () => {
|
|
354
360
|
exited = true;
|
|
355
361
|
});
|
|
362
|
+
const size = new Promise((resolve) => {
|
|
363
|
+
let acc = "";
|
|
364
|
+
let settled = false;
|
|
365
|
+
const done = (v) => {
|
|
366
|
+
if (!settled) {
|
|
367
|
+
settled = true;
|
|
368
|
+
resolve(v);
|
|
369
|
+
}
|
|
370
|
+
};
|
|
371
|
+
const out = child.stdout;
|
|
372
|
+
if (!out) return done(null);
|
|
373
|
+
out.setEncoding("utf8");
|
|
374
|
+
out.on("data", (chunk) => {
|
|
375
|
+
acc += chunk;
|
|
376
|
+
const m = acc.match(/OCSIZE\s+(\d+)\s+(\d+)/);
|
|
377
|
+
if (m) {
|
|
378
|
+
pdebug("pump reported console size", m[1], "x", m[2]);
|
|
379
|
+
done({ cols: Number(m[1]), rows: Number(m[2]) });
|
|
380
|
+
}
|
|
381
|
+
});
|
|
382
|
+
out.on("error", () => done(null));
|
|
383
|
+
out.on("end", () => done(null));
|
|
384
|
+
setTimeout(() => done(null), 2500);
|
|
385
|
+
});
|
|
356
386
|
return {
|
|
387
|
+
size,
|
|
357
388
|
write: (d) => {
|
|
358
389
|
try {
|
|
359
390
|
stdin.write(d);
|
|
@@ -807,13 +838,13 @@ function main() {
|
|
|
807
838
|
}
|
|
808
839
|
const mediaRowCount = isVisualMedia ? Math.max(8, Math.min(16, Math.floor((termRows - 14) / 2) * 2)) : MEDIA_ROWS;
|
|
809
840
|
const effectiveRows = sideMedia ? 5 : mediaRowCount;
|
|
810
|
-
|
|
841
|
+
let width = Math.min(maxWidth, cols - 4);
|
|
811
842
|
if (width < 24) {
|
|
812
843
|
sink.close();
|
|
813
844
|
return;
|
|
814
845
|
}
|
|
815
|
-
|
|
816
|
-
|
|
846
|
+
let inner = width - 4;
|
|
847
|
+
let col = Math.max(1, cols - width - 1);
|
|
817
848
|
const startRow = 2;
|
|
818
849
|
const painterStartedAt = Date.now();
|
|
819
850
|
const dim = color ? `${ESC}[2m` : "";
|
|
@@ -1319,6 +1350,14 @@ function main() {
|
|
|
1319
1350
|
};
|
|
1320
1351
|
if (IS_WINDOWS) {
|
|
1321
1352
|
void (async () => {
|
|
1353
|
+
const real = sink.size ? await sink.size : null;
|
|
1354
|
+
if (real && real.cols >= 24) {
|
|
1355
|
+
cols = real.cols;
|
|
1356
|
+
width = Math.min(maxWidth, cols - 4);
|
|
1357
|
+
inner = width - 4;
|
|
1358
|
+
col = Math.max(1, cols - width - 1);
|
|
1359
|
+
pdebug("windows geometry from pump:", "cols", cols, "width", width, "col", col);
|
|
1360
|
+
}
|
|
1322
1361
|
if (format === "image" || format === "logo" || format === "gif" || format === "video") {
|
|
1323
1362
|
await upgradeVisual();
|
|
1324
1363
|
} else if (format === "audio") {
|