From e739a350a0dff899c4161d5d5f7f7ba0dfcb4e16 Mon Sep 17 00:00:00 2001 From: subshell Date: Sun, 29 Dec 2024 22:51:29 +0000 Subject: [PATCH] remove sixel banner due to deno incompatibility --- init.ts | 57 -------------------------------------------------------- sixel.ts | 2 +- 2 files changed, 1 insertion(+), 58 deletions(-) diff --git a/init.ts b/init.ts index 5360ac3..a0b7d98 100644 --- a/init.ts +++ b/init.ts @@ -6,16 +6,7 @@ import { import { GearApi } from "https://gear-js.deno.dev/api/src/index.ts"; import { Client } from "https://deno.land/x/subshell@0.2.45/client/mod.ts"; // import { VerboseSigner } from "https://deno.land/x/subshell@0.2.45/signer/mod.ts"; -import { fromPng } from "npm:@rgba-image/png"; -import * as sixel from "npm:sixel"; import { stringToU8a } from "https://deno.land/x/polkadot@0.2.45/util/mod.ts"; -import { - ImageMagick, - initializeImageMagick, - MagickGeometry, -} from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts"; - -await initializeImageMagick(); const GEAR = !!Deno.env.get("GEAR"); const DEFAULT_PROVIDER = GEAR @@ -26,52 +17,6 @@ const PROVIDER = Deno.env.get("PROVIDER") ?? DEFAULT_PROVIDER; const TYPES = JSON.parse(Deno.env.get("TYPES") ?? "null"); const HUB = Deno.env.get("HUB") ?? `ws://localhost:8000`; -async function image2sixel(imageBuffer: Uint8Array): Uint8Array { - let resizedBuffer = await new Promise((resolve) => { - ImageMagick.read(imageBuffer, (image) => { - // console.log(image.width, image.height); - let scaleFactor = 160.0 / image.height; - const sizingData = new MagickGeometry( - image.width * scaleFactor, - image.height * scaleFactor, - ); - image.resize(sizingData); - image.write((data) => resolve(data)); - }); - }); - - let s = await fromPng(resizedBuffer); - - return stringToU8a(sixel.image2sixel(s.data, s.width, s.height)); -} - -export async function showBanner() { - const { columns } = Deno.consoleSize(0); // --unstable - if (columns <= 100) { - return; - } - - let SubshellBannerURL = - "https://raw.githubusercontent.com/subdirectory/subshell/main/.github/SubshellBanner.png"; - let SubshellBannerImage = new Uint8Array( - await (await fetch(SubshellBannerURL)).arrayBuffer(), - ); - let SubshellBannerSixel = await image2sixel(SubshellBannerImage); - - let GearShellBannerURL = - "https://raw.githubusercontent.com/subdirectory/subshell/main/.github/GearShellBanner.png"; - let GearShellBannerImage = new Uint8Array( - await (await fetch(GearShellBannerURL)).arrayBuffer(), - ); - let GearShellBannerSixel = await image2sixel(GearShellBannerImage); - - if (GEAR) { - await Deno.stdout.write(GearShellBannerSixel); - } else { - await Deno.stdout.write(SubshellBannerSixel); - } -} - function progInfo() { /* print program info from package.json */ @@ -98,8 +43,6 @@ Deno.addSignalListener("SIGINT", () => { console.log("interrupted!"); }); -await showBanner(); - progInfo(); console.log(); diff --git a/sixel.ts b/sixel.ts index 4b03edb..05369ea 100755 --- a/sixel.ts +++ b/sixel.ts @@ -7,7 +7,7 @@ import { ImageMagick, initializeImageMagick, MagickGeometry, -} from "https://deno.land/x/imagemagick_deno@0.0.14/mod.ts"; +} from "https://deno.land/x/imagemagick_deno@0.0.31/mod.ts"; await initializeImageMagick();