From d0f4913369514f37c439aae89deac3d3289034f5 Mon Sep 17 00:00:00 2001 From: ful1e5 <24286590+KaizIqbal@users.noreply.github.com> Date: Sat, 15 Aug 2020 17:29:18 +0530 Subject: [PATCH] =?UTF-8?q?=F0=9F=8F=B7=EF=B8=8F=20types=20added?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/shared/src/index.ts | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) diff --git a/packages/shared/src/index.ts b/packages/shared/src/index.ts index 57c6f473..7f57f0f7 100644 --- a/packages/shared/src/index.ts +++ b/packages/shared/src/index.ts @@ -2,7 +2,29 @@ import fs from "fs"; import path from "path"; import puppeteer from "puppeteer"; -import { generateRenderTemplate } from "@helpers/htmlTemplate"; +import { generateRenderTemplate } from "./helpers/htmlTemplate"; + +// --------------------------- Types +type AnimatedCursors = { + readonly [name: string]: { + readonly frames: number; + }; +}; + +type AnimatedClip = { + readonly x: number; + readonly y: number; + readonly width: number; + readonly height: number; +}; + +interface Config { + staticSvgs: Array; + bitmapsDir: string; + svgsDir: string; + animatedCursors: AnimatedCursors; + animatedClip: AnimatedClip; +} // --------------------------- Helpers const frameNumber = (number: number, length: number) => { @@ -19,15 +41,15 @@ export const renderCursors = async ({ bitmapsDir, svgsDir, animatedCursors, - animatedClip, -}: RenderConfig) => { + animatedClip +}: Config) => { const browser = await puppeteer.launch({ ignoreDefaultArgs: [" --single-process ", "--no-sandbox"], executablePath: process.env.NODE_ENV == "development" ? "/usr/bin/google-chrome-stable" : "", - headless: true, + headless: true }); try { console.log("📸 Rendering Static Cursors..."); @@ -93,7 +115,7 @@ export const renderCursors = async ({ await svgElement.screenshot({ omitBackground: true, path: out, - clip: animatedClip, + clip: animatedClip }); // console.log(`${svg} frame ${frame}/${frames} rendered at ${out}`); }