Skip to content

Commit

Permalink
feat(): convert examples to ts and add new examples for circle type. F…
Browse files Browse the repository at this point in the history
…ixes #23
  • Loading branch information
AlenVelocity committed Feb 5, 2022
1 parent a9ddd6c commit 75f889f
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
34 changes: 34 additions & 0 deletions examples/circle.ts
Original file line number Diff line number Diff line change
@@ -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}`)
})()
})()
2 changes: 1 addition & 1 deletion examples/crop.mjs → examples/crop.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sticker } from '../dist/index.js'
import { Sticker } from '../src'
;(async () => {
console.log('\n---\n')
console.log('Crop example')
Expand Down
2 changes: 1 addition & 1 deletion examples/default.mjs → examples/default.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sticker } from '../dist/index.js'
import { Sticker } from '../src'
;(async () => {
console.log('\n---\n')
console.log('Example')
Expand Down
2 changes: 1 addition & 1 deletion examples/full.mjs → examples/full.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Sticker } from '../dist/index.js'
import { Sticker } from '../src'
;(async () => {
console.log('\n---\n')
console.log('Full example')
Expand Down
5 changes: 0 additions & 5 deletions examples/index.mjs

This file was deleted.

9 changes: 9 additions & 0 deletions examples/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// eslint-disable-next-line @typescript-eslint/triple-slash-reference
/// <reference path='../src/internal/node-webmux' />

;(async () => {
//await import('./default')
//await import('./crop')
// await import('./full')
await import('./circle')
})().catch(console.error)
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
},
Expand Down

0 comments on commit 75f889f

Please sign in to comment.