oberconcejo/VS-CODE / .agents/skills/app-store-screenshots
app-store-screenshots
FlaggedUse when building App Store or Google Play screenshot pages, generating exportable marketing screenshots for iOS, macOS, and/or Android apps, or scaffolding a screenshot editor with Next.js. Triggers on app store, mac app store, play store, screenshots, marketing assets, html-to-image, phone mockup, mac mockup, android screenshots, feature graphic.
template/src/lib/png-encode.ts
View on GitHub"use client";
// Canvas → 24-bit RGB PNG bytes (see png-rgb.ts for why not toDataURL).
// Encoding a full-size export is ~100ms of filtering and deflate, so it runs
// on a small worker pool: exports keep rendering the next screen meanwhile.
// Without workers, or if one fails, the same encoder runs inline.
import { encodeRgbPixels } from "./png-rgb";
type Job = {
worker: Worker;
pixels: Uint8ClampedArray;
width: number;
height: number;
resolve: (png: Uint8Array) => void;
reject: (error: unknown) => void;
timeout: ReturnType<typeof setTimeout>;
};
type Result = { id: number; png?: Uint8Array; error?: string };
let pool: Worker[] | null = null;
let nextWorker = 0;
let nextId = 0;
const jobs = new Map<number, Job>();
function encodeInline(job: Job) {
clearTimeout(job.timeout);
encodeRgbPixels(job.pixels, job.width, job.height).then(job.resolve, job.reject);
}
function retireWorker(worker: Worker) {
worker.terminate();
pool = (pool || []).filter((w) => w !== worker);
for (const [id, job] of jobs) {
if (job.worker !== worker) continue;
jobs.delete(id);
encodeInline(job);
}
}
function workers(): Worker[] {
if (pool) return pool;
pool = [];
try {
const size = Math.max(1, Math.min(4, (navigator.hardwareConcurrency || 2) - 1));
for (let i = 0; i < size; i++) {
const worker = new Worker(new URL("./png-worker.ts", import.meta.url));
worker.onmessage = ({ data }: MessageEvent<Result>) => {
const job = jobs.get(data.id);
if (!job) return;
jobs.delete(data.id);
clearTimeout(job.timeout);
if (data.png) job.resolve(data.png);
else encodeInline(job);
};
// A worker that fails to load or crashes leaves the pool, and its jobs
// finish inline instead of leaving the export waiting forever.
worker.onerror = (event) => {
event.preventDefault();
retireWorker(worker);
};
worker.onmessageerror = () => retireWorker(worker);
pool.push(worker);
}
} catch {
// Keep any workers that did start; an empty pool means inline encoding.
}
return pool;
}
export function encodeCanvasPng(canvas: HTMLCanvasElement): Promise<Uint8Array> {
const ctx = canvas.getContext("2d");
if (!ctx) return Promise.reject(new Error("Canvas 2D context unavailable"));
const { width, height } = canvas;
const pixels = ctx.getImageData(0, 0, width, height).data;
const available = workers();
if (!available.length) return encodeRgbPixels(pixels, width, height);
const id = nextId++;
const worker = available[nextWorker++ % available.length];
return new Promise((resolve, reject) => {
const timeout = setTimeout(() => retireWorker(worker), 15000);
jobs.set(id, { worker, pixels, width, height, resolve, reject, timeout });
// Copied, not transferred: the pixels stay here for the inline fallback.
try { worker.postMessage({ id, pixels, width, height }); }
catch { retireWorker(worker); }
});
}
Related skills
| Skill | Stars | Updated | Works with | Status | Install |
|---|---|---|---|---|---|
| slack-gif-creatoranthropics/skillsKnowledge and utilities for creating animated GIFs optimized for Slack. Provides constraints, validation tools, and animation concepts. Use when users request animated GIFs for Slack like "make me a GIF of X doing Y for Slack." | Stars: 197k | Updated | Claude CodeCodex | Verified | Install |
| ponytailDietrichGebert/ponytailLazy senior dev mode for any coding task: the smallest change that fully solves it, and a reply a busy human understands in one read. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailHarvest every shortcut: comment into one debt ledger, so deferrals get tracked instead of forgotten. One-shot report. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |
| ponytail-debtDietrichGebert/ponytailList every `shortcut:` comment (and older `ponytail:` ones) as a debt ledger. One-shot report, changes nothing. Use for "ponytail debt", "what did ponytail defer", "list the shortcuts", /ponytail-debt. | Stars: 194k | Updated | Claude CodeCodex | Verified | Install |