Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,20 @@ jobs:

steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- uses: styfle/cancel-workflow-action@0.11.0
- uses: styfle/cancel-workflow-action@0.12.1
with:
workflow_id: ci.yml
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- uses: actions/checkout@v5
with:
fetch-depth: 30

- uses: FranzDiebold/github-env-vars-action@v2
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v5
with:
node-version: 19
node-version: 24

- name: Yarn
run: yarn install --frozen-lockfile
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ jobs:

steps:
- run: echo "πŸŽ‰ The job was automatically triggered by a ${{ github.event_name }} event."
- uses: styfle/cancel-workflow-action@0.11.0
- uses: styfle/cancel-workflow-action@0.12.1
with:
workflow_id: release.yml
access_token: ${{ github.token }}

- uses: actions/checkout@v3
- uses: actions/checkout@v5
with:
fetch-depth: 30

- uses: FranzDiebold/github-env-vars-action@v2
- name: Setup Node.js
uses: actions/setup-node@v3
uses: actions/setup-node@v5
with:
node-version: 19
node-version: 24

- name: Yarn
run: yarn install --frozen-lockfile
Expand Down
50 changes: 25 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
{
"name": "@devmehq/react-qr-code",
"version": "1.0.9",
"private": false,
"description": "React component to generate QR codes",
"keywords": [
"react",
Expand Down Expand Up @@ -43,7 +42,7 @@
"build": "rollup -c rollup.config.mjs",
"build:prod": "NODE_ENV=production rollup -c rollup.config.mjs",
"lint-js": "eslint src/**/*.ts",
"prepare": "yarn husky install",
"prepare": "husky",
"prepublishOnly": "rm -rf dist/* && NODE_ENV=production rollup -c rollup.config.mjs",
"prettier": "prettier --write '**/*.{ts,tsx,css,scss}'",
"test": "echo \"Error: no test specified\"",
Expand All @@ -54,32 +53,33 @@
"__tests__/*.{ts,tsx,js,jsx}": "prettier --write"
},
"devDependencies": {
"@ianvs/prettier-plugin-sort-imports": "3.7.1",
"@rollup/plugin-commonjs": "24.0.0",
"@rollup/plugin-node-resolve": "15.0.1",
"@rollup/plugin-replace": "5.0.2",
"@rollup/plugin-typescript": "11.0.0",
"@types/jasmine": "4.3.1",
"@types/jest": "29.2.5",
"@types/react": "18.0.26",
"@types/react-dom": "18.0.10",
"@typescript-eslint/eslint-plugin": "5.48.2",
"@typescript-eslint/parser": "5.48.2",
"eslint": "8.32.0",
"eslint-config-prettier": "8.6.0",
"husky": "8.0.3",
"jest": "29.3.1",
"lint-staged": "13.1.0",
"prettier": "2.8.3",
"pretty-quick": "3.1.3",
"rollup": "3.10.0",
"@ianvs/prettier-plugin-sort-imports": "4.7.0",
"@rollup/plugin-commonjs": "28.0.6",
"@rollup/plugin-node-resolve": "16.0.1",
"@rollup/plugin-replace": "6.0.2",
"@rollup/plugin-typescript": "12.1.4",
"@types/jasmine": "5.1.9",
"@types/jest": "30.0.0",
"@types/react": "19.1.12",
"@types/react-dom": "19.1.9",
"@typescript-eslint/eslint-plugin": "8.42.0",
"@typescript-eslint/parser": "8.42.0",
"eslint": "9.35.0",
"eslint-config-prettier": "10.1.8",
"husky": "9.1.7",
"jest": "30.1.3",
"lint-staged": "16.1.6",
"prettier": "3.6.2",
"pretty-quick": "4.2.2",
"rollup": "4.50.0",
"rollup-plugin-uglify": "6.0.4",
"ts-jest": "29.0.5",
"tslib": "2.4.1",
"typescript": "4.9.4"
"ts-jest": "29.4.1",
"tslib": "2.8.1",
"typescript": "5.9.2"
},
"peerDependencies": {
"react": ">=17.0.2",
"react-dom": ">=17.0.2"
}
},
"packageManager": "yarn@1.22.22"
}
6 changes: 3 additions & 3 deletions src/qr-js/js-qr-code.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { QRRSBlock } from './qr-rs-block'
import { QrBitBuffer } from './qr-bit-buffer'
import { QRPolynomial } from './qr-polynomial'

function JsQrCode(typeNumber: any, errorCorrectLevel: any) {
function JsQrCode(typeNumber: number, errorCorrectLevel: number) {
this.typeNumber = typeNumber
this.errorCorrectLevel = errorCorrectLevel
this.modules = null
Expand All @@ -17,12 +17,12 @@ function JsQrCode(typeNumber: any, errorCorrectLevel: any) {
const proto = JsQrCode.prototype

proto.addData = function (data: any) {
var newData = new QR8bitByte(data)
const newData = new QR8bitByte(data)
this.dataList.push(newData)
this.dataCache = null
}

proto.isDark = function (row: string | number, col: string | number) {
proto.isDark = function (row: number, col: number) {
if (
row < 0 ||
this.moduleCount <= row ||
Expand Down
2 changes: 1 addition & 1 deletion src/qr-js/qr-8-bit-byte.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { qrModeEnum } from './qr-mode-enum'

function QR8bitByte(data) {
function QR8bitByte(data: number[]) {
this.mode = qrModeEnum.MODE_8BIT_BYTE
this.data = data
}
Expand Down
6 changes: 3 additions & 3 deletions src/qr-js/qr-bit-buffer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ function QrBitBuffer() {
}

QrBitBuffer.prototype = {
get: function (index) {
get: function (index: number) {
const bufIndex = Math.floor(index / 8)
return ((this.buffer[bufIndex] >>> (7 - (index % 8))) & 1) == 1
},

put: function (num, length) {
put: function (num: number, length: number) {
for (let i = 0; i < length; i++) {
this.putBit(((num >>> (length - i - 1)) & 1) == 1)
}
Expand All @@ -20,7 +20,7 @@ QrBitBuffer.prototype = {
},

putBit: function (bit) {
var bufIndex = Math.floor(this.length / 8)
const bufIndex = Math.floor(this.length / 8)
if (this.buffer.length <= bufIndex) {
this.buffer.push(0)
}
Expand Down
4 changes: 2 additions & 2 deletions src/qr-js/qr-math.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
const QRMath = {
glog: function (n) {
glog: function (n: number) {
if (n < 1) {
throw new Error('glog(' + n + ')')
}

return QRMath.LOG_TABLE[n]
},

gexp: function (n) {
gexp: function (n: number) {
while (n < 0) {
n += 255
}
Expand Down
9 changes: 6 additions & 3 deletions src/qr-js/qr-rs-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ const RS_BLOCK_TABLE = [
[20, 45, 15, 61, 46, 16],
]

function getRsBlockTable(typeNumber, errorCorrectLevel) {
function getRsBlockTable(typeNumber: number, errorCorrectLevel: number) {
switch (errorCorrectLevel) {
case qrErrorCorrectLevel.L:
return RS_BLOCK_TABLE[(typeNumber - 1) * 4]
Expand All @@ -262,12 +262,15 @@ function getRsBlockTable(typeNumber, errorCorrectLevel) {
}
}

function QRRSBlock(totalCount, dataCount?) {
function QRRSBlock(totalCount: number, dataCount?: number) {
this.totalCount = totalCount
this.dataCount = dataCount
}

QRRSBlock.getRSBlocks = function (typeNumber, errorCorrectLevel) {
QRRSBlock.getRSBlocks = function (
typeNumber: number,
errorCorrectLevel: number
) {
const rsBlock = getRsBlockTable(typeNumber, errorCorrectLevel)

if (rsBlock == undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/qr-js/qr-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ const QRUtil = {
return a
},

getLengthInBits: function (mode: number, type: string | number) {
getLengthInBits: function (mode: number, type: number) {
if (1 <= type && type < 10) {
// 1 - 9

Expand Down
Loading