Skip to content

Commit 077346a

Browse files
committed
Initial commit
0 parents  commit 077346a

28 files changed

+4527
-0
lines changed

.github/workflows/publish.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# This workflow defines the automated publish process for the
2+
# Vertopal JavaScript Library, triggered by semantic version tags (vX.Y.Z).
3+
# It builds the package, publishes it to npm, and creates a corresponding
4+
# GitHub Release to keep the registry and repository in sync.
5+
6+
name: Publish
7+
8+
on:
9+
push:
10+
tags:
11+
- 'v[0-9]+.[0-9]+.[0-9]+'
12+
13+
permissions:
14+
id-token: write
15+
contents: write
16+
17+
jobs:
18+
release:
19+
name: Create GitHub Release
20+
runs-on: ubuntu-latest
21+
steps:
22+
- name: Checkout repository
23+
uses: actions/checkout@v4
24+
25+
- name: Create Release
26+
uses: softprops/action-gh-release@v1
27+
with:
28+
name: "Vertopal JavaScript Library ${{ github.ref_name }}"
29+
prerelease: false
30+
31+
publish:
32+
name: Publish to npm
33+
runs-on: ubuntu-latest
34+
needs: release
35+
steps:
36+
- name: Checkout repository
37+
uses: actions/checkout@v4
38+
39+
- name: Setup Node.js
40+
uses: actions/setup-node@v4
41+
with:
42+
node-version: '20'
43+
registry-url: 'https://registry.npmjs.org'
44+
45+
- name: Install dependencies
46+
run: npm ci
47+
48+
- name: Build package
49+
run: npm run build
50+
51+
- name: Publish to npm
52+
run: npm publish --provenance --access public
53+
env:
54+
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
lib/

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2025 Vertopal
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Vertopal-JS
2+
3+
Vertopal-JS is a JavaScript library for easy access to the
4+
[Vertopal file conversion API](https://www.vertopal.com/en/developer/api).
5+
6+
Using Vertopal-JS, you can quickly integrate support for
7+
converting **350+ file formats** directly into your Node.js or
8+
browser-based projects.
9+
10+
## Installing Vertopal-JS
11+
12+
Vertopal-JS is available on
13+
[npm](https://www.npmjs.com/package/vertopal-js) and can be installed using
14+
[npm](https://www.npmjs.com/):
15+
16+
```bash
17+
npm install vertopal-js
18+
```
19+
20+
If you're not using npm, you can also download the most recent version of
21+
Vertopal-JS source code as a ZIP file from the
22+
[release page](https://github.com/vertopal/vertopal-js/releases/latest) and
23+
import it manually into your project.
24+
25+
## Using Vertopal-JS
26+
27+
## JavaScript Usage
28+
29+
This package includes a public default credential (app: `free`, token:
30+
`FREE-TOKEN`) that lets you quickly experiment without creating an account.
31+
This credential is intended for personal testing and evaluation and comes
32+
with daily rate limits. For production workloads, or if you expect to exceed
33+
the free limits, you should
34+
[obtain a private Application ID and Security Token](https://www.vertopal.com/en/account/api/app/new)
35+
from your Vertopal account and configure them for full access.
36+
37+
The following code illustrates
38+
[GIF to APNG](https://www.vertopal.com/en/convert/gif-to-apng) conversion using
39+
the Vertopal JavaScript library.
40+
41+
```javascript
42+
// Import Vertopal classes
43+
import { Credential, Converter } from 'vertopal';
44+
import { FileInput, FileOutput } from 'vertopal/io';
45+
46+
// Create a client credential instance using your app ID and security token
47+
const app = "free";
48+
const token = "FREE-TOKEN";
49+
const credential = new Credential(app, token);
50+
51+
/**
52+
* Initialize input and output file streams
53+
*
54+
* Node.js-compatible file I/O:
55+
* - `FileInput` reads from a local file path (e.g., "./MickeyMouse.gif")
56+
* - `FileOutput` writes to a local file path (e.g., "./MickeyMouse.apng")
57+
*
58+
* Browser-compatible file I/O:
59+
* - `BrowserFileInput` reads from browser sources (e.g., <input type="file"> or drag-and-drop)
60+
* - `BrowserFileOutput` writes to browser sinks (e.g., triggering a download or streaming to canvas)
61+
*/
62+
const source = new FileInput("./MickeyMouse.gif");
63+
const sink = new FileOutput("./MickeyMouse.apng");
64+
65+
// Convert and download your file using the Converter class
66+
(async () => {
67+
const converter = new Converter(credential);
68+
const conversion = await converter.convert(source, sink, "apng");
69+
await conversion.wait();
70+
if (conversion.successful()) {
71+
await conversion.download();
72+
}
73+
})();
74+
```

eslint.config.mjs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import js from "@eslint/js";
2+
import globals from "globals";
3+
import tseslint from "typescript-eslint";
4+
import { defineConfig } from "eslint/config";
5+
6+
export default defineConfig([
7+
{
8+
files: ["**/*.{js,mjs,cjs,ts,mts,cts}"],
9+
plugins: { js },
10+
extends: ["js/recommended"],
11+
languageOptions: {
12+
globals: { ...globals.browser, ...globals.node },
13+
},
14+
},
15+
{
16+
extends: [tseslint.configs.recommended],
17+
files: ["**/*.{ts,tsx,mts,cts}"],
18+
rules: {
19+
"@typescript-eslint/no-explicit-any": "warn",
20+
},
21+
},
22+
]);

0 commit comments

Comments
 (0)