Open qrcode in Script Kit

// Shortcut: control option q
// Name: qrcode
// Description: generate qrcode from input and display
// Author: Minatohikari
import "@johnlindquist/kit";
import { promisify } from "util";
const { toDataURL }: typeof import("qrcode") = await npm("qrcode");
const text = await arg("input text to get qrcode");
const width = 300;
const toDataURLPromise = promisify((...args: Parameters<typeof toDataURL>) =>
toDataURL(...args)
);
const url = await toDataURLPromise(text, { width });
const img = `<img src="${url}" alt="Generate failed" width="${width}" height="${width}" />`;
await widget(`<div>${img}</div>`, {
width,
height: width,
});