Skip to content

Commit

Permalink
fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Dunkel committed Jan 6, 2024
1 parent 3ff8bc1 commit 99d2b6f
Show file tree
Hide file tree
Showing 7 changed files with 27 additions and 12 deletions.
18 changes: 18 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
on:
push:
branches: main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v3
with:
node-version: "20"
- run: npm install
- run: npm run build
- uses: JS-DevTools/npm-publish@v3
with:
token: ${{ secrets.NPM_TOKEN }}
strategy: upgrade
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ node_modules
**/*.js
**/*.d.ts

!qr.d.ts
!qrpng.d.ts
!rollup.config.js
1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock = false
5 changes: 0 additions & 5 deletions lib/png.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,6 @@ function setUint32(buffer: ArrayBuffer, offset: number, value: number) {
}

function compileData(data: boolean[][]): { width: number; height: number; data: Uint8Array } {
console.error(printmap(data));
const height = Math.ceil(data.length / 8) * 8;
const width = Math.ceil(data[0].length / 8) * 8;
const buffer = new Uint8Array(((width + 1) * height) / 8);
Expand All @@ -109,7 +108,3 @@ function compileData(data: boolean[][]): { width: number; height: number; data:
const result = deflate(buffer);
return { width, height, data: result };
}

function printmap(data: boolean[][]) {
return data.map((l) => l.map((p) => (p ? "*" : " ")).join("")).join("\n");
}
9 changes: 5 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@
"name": "qrpng",
"version": "1.0.1",
"description": "Quickly create a QR-Code PNG in pure JavaScript",
"main": "./qr.js",
"main": "./qrpng.js",
"files": [
"qr.js",
"qr.d.ts",
"qrpng.js",
"qrpng.d.ts",
"Readme.md"
],
"scripts": {
"build": "tsc && rollup -c rollup.config.js",
"prepublishOnly": "npm run build"
"prepublishOnly": "npm run build",
"postversion": "git push --follow-tags"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion qr.d.ts → qrpng.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
declare module "qr" {
declare module "qrpng" {
function generate(test: string, scale?: number): Uint8Array;
export = generate;
}
2 changes: 1 addition & 1 deletion rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const config = {
input: "lib/qr.js",
output: {
name: "qrpng",
file: "qr.js",
file: "qrpng.js",
format: "cjs",
exports: "default",
},
Expand Down

0 comments on commit 99d2b6f

Please sign in to comment.