@opencrater/sdk 0.8.53 → 0.8.54

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.

Files changed (2) hide show
  1. package/dist/hook.js +22 -0
  2. package/package.json +1 -1
package/dist/hook.js CHANGED
@@ -778,6 +778,23 @@ async function renderPlain(card, state, media, impressionId, campaignId) {
778
778
  }
779
779
  return { ...state, lastShownAt: Date.now(), disclosureShown: true };
780
780
  }
781
+ function windowsCardShowing(displayMs) {
782
+ if (process.platform !== "win32") return false;
783
+ try {
784
+ const lockPath = path3__namespace.join(os2__namespace.homedir(), ".config", "opencrater", "painter.lock");
785
+ const lock = JSON.parse(fs3__namespace.readFileSync(lockPath, "utf8"));
786
+ if (typeof lock.pid !== "number" || typeof lock.startedAt !== "number") return false;
787
+ if (Date.now() - lock.startedAt > displayMs + 1e3) return false;
788
+ try {
789
+ process.kill(lock.pid, 0);
790
+ } catch {
791
+ return false;
792
+ }
793
+ return true;
794
+ } catch {
795
+ return false;
796
+ }
797
+ }
781
798
  var RENDER_SLOT_TTL_MS = 8e3;
782
799
  function claimRenderSlot() {
783
800
  const slot = path3__namespace.join(os2__namespace.homedir(), ".config", "opencrater", "render.lock");
@@ -902,6 +919,11 @@ async function main() {
902
919
  debug("hook: pooled ad skipped \u2014 campaign inside a local cooldown");
903
920
  ({ ad: pooled, pool } = takeFromPool({ pool }, Date.now()));
904
921
  }
922
+ if ((pooled || args.key) && windowsCardShowing((config.displayDurationSeconds ?? 25) * 1e3)) {
923
+ writeState(state);
924
+ debug("hook: a card is already on screen \u2014 not rendering another");
925
+ return;
926
+ }
905
927
  if (pooled || args.key) {
906
928
  if (!claimRenderSlot()) {
907
929
  writeState(state);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opencrater/sdk",
3
- "version": "0.8.53",
3
+ "version": "0.8.54",
4
4
  "description": "OpenCrater SDK — sponsor cards for CLI tools and MCP servers. Fail-silent, zero dependencies.",
5
5
  "keywords": [
6
6
  "opencrater",