From 75f889f330d999a10b005b5c71017e1137153ba6 Mon Sep 17 00:00:00 2001 From: alensaito1 Date: Sat, 5 Feb 2022 13:38:05 +0530 Subject: [PATCH] feat(): convert examples to ts and add new examples for circle type. Fixes #23 --- examples/circle.ts | 34 ++++++++++++++++++++++++++++ examples/{crop.mjs => crop.ts} | 2 +- examples/{default.mjs => default.ts} | 2 +- examples/{full.mjs => full.ts} | 2 +- examples/index.mjs | 5 ---- examples/index.ts | 9 ++++++++ package.json | 5 ++-- 7 files changed, 49 insertions(+), 10 deletions(-) create mode 100644 examples/circle.ts rename examples/{crop.mjs => crop.ts} (97%) rename examples/{default.mjs => default.ts} (97%) rename examples/{full.mjs => full.ts} (98%) delete mode 100644 examples/index.mjs create mode 100644 examples/index.ts diff --git a/examples/circle.ts b/examples/circle.ts new file mode 100644 index 0000000..77662bc --- /dev/null +++ b/examples/circle.ts @@ -0,0 +1,34 @@ +import { Sticker } from '../src' +;(async () => { + console.log('\n---\n') + console.log('Circle example') + console.log('---\n') + const images = { + static: { + potrait: 'https://i.pinimg.com/originals/3a/53/d6/3a53d68345b56241a875595b21ec2a59.jpg', + landscape: 'https://chasinganime.com/wp-content/uploads/2021/02/0_YgtEypuJ2QfMPCbn.jpg' + }, + animated: { + potrait: 'https://c.tenor.com/-1mtmQgH5eYAAAAC/watson-amelia-vtuber.gif', + landscape: 'https://c.tenor.com/2RdLoyV5VPsAAAAC/ayame-nakiri.gif' + } + } + const type = 'circle' + const getOptions = (pack = '', author = '') => ({ + pack, + type, + author: `${author}-${type}` + }) + await (async () => { + console.log('Static Potrait') + const sticker = new Sticker(images.static.potrait, getOptions('static', 'potrait')) + await sticker.toFile() + console.log(`Saved to ${sticker.defaultFilename}`) + })() + await (async () => { + console.log('Static Landscape') + const sticker = new Sticker(images.static.landscape, getOptions('static', 'landscape')) + await sticker.toFile() + console.log(`Saved to ${sticker.defaultFilename}`) + })() +})() diff --git a/examples/crop.mjs b/examples/crop.ts similarity index 97% rename from examples/crop.mjs rename to examples/crop.ts index 9d14340..9952002 100644 --- a/examples/crop.mjs +++ b/examples/crop.ts @@ -1,4 +1,4 @@ -import { Sticker } from '../dist/index.js' +import { Sticker } from '../src' ;(async () => { console.log('\n---\n') console.log('Crop example') diff --git a/examples/default.mjs b/examples/default.ts similarity index 97% rename from examples/default.mjs rename to examples/default.ts index 005c73f..1a1ae52 100644 --- a/examples/default.mjs +++ b/examples/default.ts @@ -1,4 +1,4 @@ -import { Sticker } from '../dist/index.js' +import { Sticker } from '../src' ;(async () => { console.log('\n---\n') console.log('Example') diff --git a/examples/full.mjs b/examples/full.ts similarity index 98% rename from examples/full.mjs rename to examples/full.ts index 192f216..a004340 100644 --- a/examples/full.mjs +++ b/examples/full.ts @@ -1,4 +1,4 @@ -import { Sticker } from '../dist/index.js' +import { Sticker } from '../src' ;(async () => { console.log('\n---\n') console.log('Full example') diff --git a/examples/index.mjs b/examples/index.mjs deleted file mode 100644 index eb86188..0000000 --- a/examples/index.mjs +++ /dev/null @@ -1,5 +0,0 @@ -;(async () => { - await import('./default.mjs') - await import('./crop.mjs') - await import('./full.mjs') -})().catch(console.error) diff --git a/examples/index.ts b/examples/index.ts new file mode 100644 index 0000000..d513144 --- /dev/null +++ b/examples/index.ts @@ -0,0 +1,9 @@ +// eslint-disable-next-line @typescript-eslint/triple-slash-reference +/// + +;(async () => { + //await import('./default') + //await import('./crop') + // await import('./full') + await import('./circle') +})().catch(console.error) diff --git a/package.json b/package.json index 962fd88..4ecef1b 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,8 @@ "fmt": "prettier --config .prettierrc \"**/*.{ts,mjs}\" --write", "test": "mocha --timeout 60000 -r ts-node/register \"tests/**/*.test.ts\"", "clean:webp": "find ./ -name '*.webp' -delete", - "release": "release-it" + "release": "release-it", + "examples": "ts-node ./examples/index.ts" }, "keywords": [ "whatsapp", @@ -47,7 +48,7 @@ "prettier": "^2.3.2", "release-it": "^14.11.6", "rimraf": "^3.0.2", - "ts-node": "^10.4.0", + "ts-node": "^10.2.1", "typedoc": "^0.21.5", "typescript": "^4.3.5" },