From e23493c0b49a9fbc8578c6721715bf83712f484d Mon Sep 17 00:00:00 2001 From: Kravets <57632712+kravetsone@users.noreply.github.com> Date: Thu, 18 Jul 2024 19:16:49 +0300 Subject: [PATCH] chore: add tiny in features and fix bundling --- .github/workflows/publish.yml | 3 +++ README.md | 16 ++++++++++++++-- package.json | 5 ++++- 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 5a3ba7b..fac7ba6 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -44,6 +44,9 @@ jobs: - name: Type-check run: tsc --noEmit + - name: Run publint + run: bunx publint + - name: Setup Deno uses: denoland/setup-deno@v1 diff --git a/README.md b/README.md index 89e3383..3319777 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ [![npm](https://img.shields.io/npm/v/wrappergram?logo=npm&style=flat&labelColor=000&color=3b82f6)](https://www.npmjs.org/package/wrappergram) [![JSR](https://jsr.io/badges/@gramio/wrappergram)](https://jsr.io/@gramio/wrappergram) [![JSR Score](https://jsr.io/badges/@gramio/wrappergram/score)](https://jsr.io/@gramio/wrappergram) +[![bundlejs]()](https://bundlejs.com) @@ -17,12 +18,14 @@ Simple and tiny code-generated **Telegram Bot API** wrapper for TypeScript/JavaS 🛡️ **Type-safe** - Written in TypeScript with love ❤️ +🤏 **Tiny** - Simple `sendMessage` call cost some [![bundlejs](https://edge.bundlejs.com/?text=import%20%7B%20Telegram%20%7D%20from%20%22wrappergram%22%3B%0A%0Aconst%20telegram%20%3D%20new%20Telegram%28process.env.BOT_TOKEN%29%3B%0A%0Atelegram.api.sendMessage%28%7B%0A%20%20%20%20chat_id%3A%20617580375%2C%0A%20%20%20%20text%3A%20%22Hello%21%22%2C%0A%7D%29%3B&badge)](https://bundlejs.com/?q=wrappergram&treeshake=%5B*%5D&text=%22const+telegram+%3D+new+Telegram%28process.env.BOT_TOKEN%29%3B%5Cn%5Cntelegram.api.sendMessage%28%7B%5Cn++++chat_id%3A+617580375%2C%5Cn++++text%3A+%5C%22Hello%21%5C%22%2C%5Cn%7D%29%3B%22) in bundle size. So it is a good choice for browser/serverless environments + But if you need a more complete framework, then please look to [`GramIO`](https://gramio.dev/). ### Usage ```ts -import { Telegram } from "wrappergram"; +import { Telegram, getUpdates } from "wrappergram"; const telegram = new Telegram(process.env.BOT_TOKEN as string); @@ -43,6 +46,8 @@ for await (const update of getUpdates(telegram)) { } ``` +This example on bundlejs cost [![bundlejs]()](https://bundlejs.com/?q=wrappergram&treeshake=%5B*%5D&share=MYewdgzgLgBFCmAbeBzATgQwLYwLwzHgHcYAVJVTLACgAc0Rh4IIA6eMAN1YCEB5UgH1SfANIBRAHIBKANwAoeQmTpsrDLQCWrCBwAmAWWYQMKeNQDe8mDZjAAFhiiDNegFwwAbAEYA7AFYADgAGAGYAgBprWwQADygPACIACSREEABCRKiAXzlFADMQNBgMIgxNWGpQSFgAV1o9J3gYEAKYMygAVUbmiGplSmxpaRgrWztwCBBkVnSUagamhHzom012xd6EVixjU3gAflYChixR8YmYilUsdS0dfSMWA8s1q4mHJxd3GCXm3b7MwnM6sVxRD4fOIJGApTQZMiOMAAawgMCKJSg9haexeZmy7wmeQURPkOSAA) + > [!IMPORTANT] > Use `getUpdates` only **once** in your code otherwise it will cause double calls to [getUpdates](https://core.telegram.org/bots/api#getupdates) @@ -71,10 +76,15 @@ import { Keyboard } from "@gramio/keyboards"; telegram.api.sendMessage({ chat_id: "@gramio_forum", text: "Hello, world!", - reply_markup: new InlineKeyboard().url("GitHub", "https://github.com/gramiojs/wrappergram"); + reply_markup: new InlineKeyboard().url( + "GitHub", + "https://github.com/gramiojs/wrappergram" + ), }); ``` +This example cost - [![bundlejs]()](https://bundlejs.com/?q=wrappergram&treeshake=%5B*%5D&text=%22const+telegram+%3D+new+Telegram%28process.env.BOT_TOKEN+as+string%29%3B+%5Cn%5Cntelegram.api.sendMessage%28%7B+%5Cn++chat_id%3A+617580375%2C+%5Cn++text%3A+%5C%22Hello%21%5C%22%2C+%5Cn++reply_markup%3A+new+InlineKeyboard%28%29.url%28%5C%22GitHub%5C%22%2C+%5C%22https%3A%2F%2Fgithub.com%2Fgramiojs%2Fwrappergram%5C%22%29+%5Cn%7D%29%3B%22) + [Read more here](https://gramio.dev/keyboards/overview) ### Send files @@ -97,4 +107,6 @@ telegram.api.sendDocument({ }); ``` +This example cost - [![bundlejs]()](https://bundlejs.com/?q=wrappergram&treeshake=%5B*%5D&text=%22const+telegram+%3D+new+Telegram%28process.env.BOT_TOKEN%29%3B+%5Cn%5Cntelegram.api.sendPhoto%28%7B+%5Cn++chat_id%3A+%5C%22%40gramio_forum%5C%22%2C+%5Cn++text%3A+%5C%22Hello%2C+world%21%5C%22%2C+%5Cn++photo%3A+MediaUpload.path%28%5C%22.%2Fcute-cat.png%5C%22%29%2C+%5Cn%7D%29%3B%22) + [Read more here](https://gramio.dev/files/overview) diff --git a/package.json b/package.json index 7c57e50..5f6fd63 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "wrappergram", - "version": "0.0.1", + "version": "1.0.0", "main": "./dist/index.cjs", "description": "Simple and tiny code-generated Telegram Bot API wrapper for TypeScript/JavaScript with file upload support", "keywords": [ @@ -16,6 +16,9 @@ "tiny", "long-polling" ], + "scripts": { + "prepublishOnly": "bunx pkgroll" + }, "module": "./dist/index.js", "types": "./dist/index.d.ts", "exports": {