@opencrater/sdk 0.8.45 → 0.8.48

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/hook.js CHANGED
@@ -600,7 +600,7 @@ function topicsForRequest(stored, now) {
600
600
  }
601
601
 
602
602
  // src/hook.ts
603
- var TOTAL_BUDGET_MS = process.platform === "win32" ? 6e3 : 3200;
603
+ var TOTAL_BUDGET_MS = process.platform === "win32" ? 8e3 : 3200;
604
604
  var STDIN_BUDGET_MS = 150;
605
605
  var IMPRESSION_BUDGET_MS = 250;
606
606
  var SERVE_TIMEOUT_CEILING_MS = 2800;
@@ -769,7 +769,7 @@ async function renderPlain(card, state, media, impressionId, campaignId) {
769
769
  };
770
770
  child.on("exit", finish);
771
771
  child.on("error", finish);
772
- setTimeout(finish, 5500);
772
+ setTimeout(finish, 7500);
773
773
  });
774
774
  } else {
775
775
  child.unref();
package/dist/paint.js CHANGED
@@ -309,21 +309,13 @@ var WIN_PUMP_PS = [
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
311
  "$m=[uint32]0;[void][OCP.N]::GetConsoleMode($h,[ref]$m);[void][OCP.N]::SetConsoleMode($h,($m -bor 4));[void][OCP.N]::SetConsoleOutputCP(65001)",
312
- // Read the ENTIRE overlay frame from stdin first, THEN redraw it on a timer
313
- // for the hold window. A single write loses a race with Claude Code's TUI
314
- // (it repaints the console buffer on its own clock and overwrites our bytes
315
- // before ConPTY flushes them); re-asserting the same absolute-positioned
316
- // frame every ~150ms keeps the card continuously present until the hook
317
- // returns. The frame uses ESC7/ESC8 (save/restore cursor) so each redraw
318
- // leaves CC's own cursor untouched.
319
- "$hold=[int]($env:OPENCRATER_WIN_HOLD_MS); if($hold -le 0){$hold=1800}",
320
- "$in=[Console]::OpenStandardInput();$ms=New-Object System.IO.MemoryStream;$buf=New-Object byte[] 65536",
321
- "while(($n=$in.Read($buf,0,$buf.Length)) -gt 0){$ms.Write($buf,0,$n)}",
322
- "$data=$ms.ToArray()",
323
- "L ('pump: frame received '+$data.Length+' bytes, holding '+$hold+'ms')",
324
- "$sw=[System.Diagnostics.Stopwatch]::StartNew();$reps=0",
325
- "do{$w=[uint32]0;[void][OCP.N]::WriteFile($h,$data,$data.Length,[ref]$w,[IntPtr]::Zero);$reps++;Start-Sleep -Milliseconds 150}while($sw.ElapsedMilliseconds -lt $hold)",
326
- "L ('pump: held '+$sw.ElapsedMilliseconds+'ms, '+$reps+' redraws')"
312
+ // Stream frames straight to the console as they arrive. The painter drives
313
+ // the timing it repaints the overlay (live countdown, position defence)
314
+ // every ~300ms and finally writes an erase frame, then closes the pipe; we
315
+ // simply forward each chunk to the visible buffer until EOF.
316
+ "$in=[Console]::OpenStandardInput();$buf=New-Object byte[] 65536;$tot=0;$frames=0",
317
+ "while(($n=$in.Read($buf,0,$buf.Length)) -gt 0){$w=[uint32]0;[void][OCP.N]::WriteFile($h,$buf,$n,[ref]$w,[IntPtr]::Zero);$tot+=$w;$frames++}",
318
+ "L ('pump: stdin closed, streamed '+$tot+' bytes in '+$frames+' chunks')"
327
319
  ].join("\n");
328
320
  function powershellPath() {
329
321
  const root = process.env["SystemRoot"] || process.env["windir"] || "C:\\Windows";
@@ -829,7 +821,7 @@ function main() {
829
821
  const reset = color ? `${ESC}[0m` : "";
830
822
  const format = fmt;
831
823
  const protocol = detectImageProtocol(process.env);
832
- const flowMode = process.env["OPENCRATER_FLOW"] === "1" || IS_WINDOWS;
824
+ const flowMode = process.env["OPENCRATER_FLOW"] === "1";
833
825
  const muted = process.env["OPENCRATER_MUTE"] === "1";
834
826
  const origin = payload.apiOrigin ?? "https://api.opencrater.to";
835
827
  const badge = format === "video" ? "\u25B6 " : format === "audio" ? "\u266A " : "";
@@ -1333,11 +1325,21 @@ function main() {
1333
1325
  await upgradeAudio();
1334
1326
  }
1335
1327
  if (payload.audioUrl && format !== "audio") void upgradeAudio(payload.audioUrl);
1336
- const framesNow = ansiFrames;
1337
- if (framesNow && framesNow.length > 1) {
1338
- ansiFrames = [framesNow[0]];
1339
- }
1328
+ const envHold = Number(process.env["OPENCRATER_WIN_HOLD_MS"]);
1329
+ const holdMs = envHold > 0 ? envHold : Math.min(payload.durationMs ?? DEFAULT_DURATION_MS, 5e3);
1330
+ deadlineAt = Date.now() + holdMs;
1340
1331
  sink.write(buildFrame());
1332
+ await new Promise((resolve) => {
1333
+ const iv = setInterval(() => {
1334
+ if (Date.now() >= deadlineAt) {
1335
+ clearInterval(iv);
1336
+ resolve();
1337
+ return;
1338
+ }
1339
+ sink.write(buildFrame());
1340
+ }, REPAINT_MS);
1341
+ });
1342
+ clear();
1341
1343
  if (tmpDir) {
1342
1344
  try {
1343
1345
  fs2.rmSync(tmpDir, { recursive: true, force: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrater/sdk",
3
- "version": "0.8.45",
3
+ "version": "0.8.48",
4
4
  "description": "OpenCrater SDK — sponsor cards for CLI tools and MCP servers. Fail-silent, zero dependencies.",
5
5
  "keywords": [
6
6
  "opencrater",