Skip to content

Commit

Permalink
drop webpack + new test scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
odahcam committed Oct 19, 2020
1 parent 07bdd0f commit 37f2a4f
Show file tree
Hide file tree
Showing 66 changed files with 1,024 additions and 2,907 deletions.
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,9 @@ node_modules/
*.iml

coverage
esm
esm5
umd
typings
dist
output

## this is generated by `npm pack`
*.tgz
Expand Down
54 changes: 20 additions & 34 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,48 +40,41 @@
},
"homepage": "https://zxing-js.github.io/library/",
"private": false,
"main": "./umd/index.min.js",
"main": "./es5/index.js",
"module": "./esm/index.js",
"typings": "./esm/index.d.ts",
"esnext": "./esm/index.js",
"nyc": {
"include": [
"src/**/*.ts"
],
"sourceMap": false,
"instrument": false
},
"scripts": {
"lint": "yarn tslint --project .",
"clean": "yarn shx rm -rf umd esm esm5",
"test": "yarn mocha-webpack \"./src/**/*.spec.ts\" --timeout 200000 --webpack-config webpack.config.test.js",
"test": "yarn test:build && yarn test:run",
"test:build": "tsc --build tsconfig.test.json",
"test:run": "mocha -r tsconfig-paths/register --timeout 200000 output/tests/**/*.spec.js",
"cover": "yarn nyc --reporter=lcov --reporter=text yarn test",
"build": "yarn clean && yarn build:es5 && yarn build:es6 && yarn build:umd",
"build:es5": "yarn tsc",
"build:es6": "yarn tsc --target es6 --outdir esm --module es6",
"build:umd": "yarn webpack --mode production",
"build": "yarn clean && yarn build:es5 && yarn build:es6 && yarn build:umd && yarn run build:umd:min && yarn build:copy",
"build:es5": "yarn tsc --build tsconfig.libes5.json",
"build:es6": "yarn tsc --build tsconfig.libes6.json",
"build:umd": "rollup dist/esm/index.js --format umd --name ZXingLibrary --sourceMap --output dist/umd/zxing-library.js",
"build:umd:min": "cd dist/umd && uglifyjs --compress --mangle --source-map --screw-ie8 --comments --o zxing-library.min.js -- zxing-library.js && gzip zxing-library.min.js -c > zxing-library.min.js.gz",
"build:copy": "cp README.md dist && cp package.json dist",
"shx": "./node_modules/.bin/shx",
"tsc": "./node_modules/.bin/tsc",
"tslint": "./node_modules/.bin/tslint \"./src/**/*.ts\"",
"mocha-webpack": "./node_modules/.bin/mocha-webpack",
"nyc": "./node_modules/.bin/nyc",
"webpack": "./node_modules/.bin/webpack-cli"
"tslint": "./node_modules/.bin/tslint \"./src/**/*.ts\""
},
"dependencies": {
"ts-custom-error": "^3.0.0"
},
"devDependencies": {
"@zxing/text-encoding": "~0.9.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@types/chai": "^4.1.7",
"@types/mocha": "^5.2.6",
"@types/node": "^10.12.29",
"@types/seedrandom": "^2.4.27",
"@types/sharp": "^0.22.2",
"awesome-typescript-loader": "^5.2.1",
"@zxing/text-encoding": "~0.9.0",
"chai": "^4.2.0",
"codacy-coverage": "^3.4.0",
"eslint": "^5.15.1",
"istanbul-instrumenter-loader": "^3.0.1",
"karma": "^3.1.4",
"karma-chai": "^0.1.0",
"karma-chrome-launcher": "^2.2.0",
Expand All @@ -92,27 +85,20 @@
"karma-sourcemap-loader": "^0.3.7",
"karma-typescript": "^3.0.13",
"karma-typescript-preprocessor": "^0.4.0",
"karma-webpack": "^3.0.5",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "^1.3.0",
"mocha-webpack": "^2.0.0-beta.0",
"nyc": "^13.3.0",
"rollup": "^2.8.2",
"seedrandom": "^2.4.4",
"sharp": "^0.22.1",
"shx": "0.3.2",
"sinon": "^7.2.7",
"ts-loader": "^5.3.3",
"ts-node": "^8.9.0",
"tslint": "^5.13.1",
"ts-mocha": "^7.0.0",
"ts-node": "^9.0.0",
"tsconfig-paths": "^3.9.0",
"tslint": "^6.1.3",
"tslint-no-circular-imports": "^0.7.0",
"typescript": "~3.3.3333",
"uglify-js": "^3.4.9",
"uglifyjs-webpack-plugin": "^2.1.2",
"webpack": "^4.29.6",
"webpack-cli": "^3.2.3",
"webpack-config-utils": "2.3.1",
"webpack-node-externals": "^1.6.0",
"yarn": "^1.17.3"
"typescript": "^3",
"uglify-js": "^2.4.11"
},
"optionalDependencies": {
"@zxing/text-encoding": "~0.9.0"
Expand Down
33 changes: 33 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,16 @@ export { default as ResultMetadataType } from './core/ResultMetadataType';
export { default as ResultPointCallback } from './core/ResultPointCallback';
export { default as RGBLuminanceSource } from './core/RGBLuminanceSource';
export { default as Writer } from './core/Writer';
export { default as ResultPoint } from './core/ResultPoint';

// core/util
export { default as ZXingSystem } from './core/util/System';
export { default as ZXingStringBuilder } from './core/util/StringBuilder';
export { default as ZXingStringEncoding } from './core/util/StringEncoding';
export { default as ZXingCharset } from './core/util/Charset';
export { default as ZXingArrays } from './core/util/Arrays';
export { default as ZXingStandardCharsets } from './core/util/StandardCharsets';
export { default as ZXingInteger } from './core/util/Integer';

// core/common
export { default as BitArray } from './core/common/BitArray';
Expand Down Expand Up @@ -60,19 +70,42 @@ export { default as ReedSolomonEncoder } from './core/common/reedsolomon/ReedSol

// core/datamatrix
export { default as DataMatrixReader } from './core/datamatrix/DataMatrixReader';
export { default as DataMatrixDecodedBitStreamParser } from './core/datamatrix/decoder/DecodedBitStreamParser';

// core/pdf417
export { default as PDF417Reader } from './core/pdf417/PDF417Reader';
export { default as PDF417ResultMetadata } from './core/pdf417/PDF417ResultMetadata';
export { default as PDF417DecodedBitStreamParser } from './core/pdf417/decoder/DecodedBitStreamParser';
export { default as PDF417DecoderErrorCorrection } from './core/pdf417/decoder/ec/ErrorCorrection';


// core/twod/qrcode
export { default as QRCodeReader } from './core/qrcode/QRCodeReader';
export { default as QRCodeWriter } from './core/qrcode/QRCodeWriter';
export { default as QRCodeDecoderErrorCorrectionLevel } from './core/qrcode/decoder/ErrorCorrectionLevel';
export { default as QRCodeDecoderFormatInformation } from './core/qrcode/decoder/FormatInformation';
export { default as QRCodeVersion } from './core/qrcode/decoder/Version';
export { default as QRCodeMode } from './core/qrcode/decoder/Mode';
export { default as QRCodeDecodedBitStreamParser } from './core/qrcode/decoder/DecodedBitStreamParser';
export { default as QRCodeDataMask } from './core/qrcode/decoder/DataMask';
export { default as QRCodeEncoder } from './core/qrcode/encoder/Encoder';
export { default as QRCodeEncoderQRCode } from './core/qrcode/encoder/QRCode';
export { default as QRCodeMatrixUtil } from './core/qrcode/encoder/MatrixUtil';
export { default as QRCodeByteMatrix } from './core/qrcode/encoder/ByteMatrix';
export { default as QRCodeMaskUtil } from './core/qrcode/encoder/MaskUtil';


// core/twod/aztec
export { default as AztecCodeReader } from './core/aztec/AztecReader';
export { default as AztecCodeWriter } from './core/aztec/AztecWriter';
export { default as AztecDetectorResult } from './core/aztec/AztecDetectorResult';
export { default as AztecEncoder } from './core/aztec/encoder/Encoder';
export { default as AztecHighLevelEncoder } from './core/aztec/encoder/HighLevelEncoder';
export { default as AztecCode } from './core/aztec/encoder/AztecCode';
export { default as AztecDecoder } from './core/aztec/decoder/Decoder';
export { default as AztecDetector } from './core/aztec/detector/Detector';
export { Point as AztecPoint } from './core/aztec/detector/Detector';


// core/oned
export { default as OneDReader } from './core/oned/OneDReader';
Expand Down
6 changes: 3 additions & 3 deletions src/test/core/PlanarYUVLuminanceSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import * as assert from 'assert';
import AssertUtils from './util/AssertUtils';
import PlanarYUVLuminanceSource from '../../core/PlanarYUVLuminanceSource';
import System from '../../core/util/System';
import { PlanarYUVLuminanceSource } from '@zxing/library';
import { ZXingSystem } from '@zxing/library';

describe('PlanarYUVLuminanceSource', () => {

Expand All @@ -36,7 +36,7 @@ describe('PlanarYUVLuminanceSource', () => {
const ROWS: number /*int*/ = 4;
const Y = new Uint8ClampedArray(COLS * ROWS);

System.arraycopy(YUV, 0, Y, 0, Y.length);
ZXingSystem.arraycopy(YUV, 0, Y, 0, Y.length);

it('testNoCrop', () => {
const source = new PlanarYUVLuminanceSource(YUV, COLS, ROWS, 0, 0, COLS, ROWS, false);
Expand Down
4 changes: 2 additions & 2 deletions src/test/core/RGBLuminanceSource.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

import * as assert from 'assert';
import AssertUtils from './util/AssertUtils';
import LuminanceSource from '../../core/LuminanceSource';
import RGBLuminanceSource from '../../core/RGBLuminanceSource';
import { LuminanceSource } from '@zxing/library';
import { RGBLuminanceSource } from '@zxing/library';

describe('RGBLuminanceSource', () => {

Expand Down
146 changes: 73 additions & 73 deletions src/test/core/SharpImageLuminanceSource.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
/*import java.awt.image.WritableRaster;*/

import SharpImage from './util/SharpImage';
import LuminanceSource from '../../core/LuminanceSource';
import InvertedLuminanceSource from '../../core/InvertedLuminanceSource';
import IllegalArgumentException from '../../core/IllegalArgumentException';
import { LuminanceSource } from '@zxing/library';
import { InvertedLuminanceSource } from '@zxing/library';
import { IllegalArgumentException } from '@zxing/library';

/**
* This LuminanceSource implementation is meant for J2SE clients and our blackbox unit tests.
Expand All @@ -36,77 +36,77 @@ import IllegalArgumentException from '../../core/IllegalArgumentException';
*/
export default class SharpImageLuminanceSource extends LuminanceSource {

public constructor(private image: SharpImage) {
super(image.getWidth(), image.getHeight());
// if (undefined === width) {
// this.width = image.getWidth()
// }
// if (undefined === height) {
// this.height = image.getHeight()
// }

// const sourceWidth: number /*int*/ = image.getWidth()
// const sourceHeight: number /*int*/ = image.getHeight()
// if (left + width > sourceWidth || top + height > sourceHeight) {
// throw new IllegalArgumentException("Crop rectangle does not fit within image data.")
// }

// if (left > 0 || width < sourceWidth || top > 0 || height < sourceHeight) {
// image.crop(left, top, width, height)
// }

// image.grayscale()
public constructor(private image: SharpImage) {
super(image.getWidth(), image.getHeight());
// if (undefined === width) {
// this.width = image.getWidth()
// }
// if (undefined === height) {
// this.height = image.getHeight()
// }

// const sourceWidth: number /*int*/ = image.getWidth()
// const sourceHeight: number /*int*/ = image.getHeight()
// if (left + width > sourceWidth || top + height > sourceHeight) {
// throw new IllegalArgumentException("Crop rectangle does not fit within image data.")
// }

// if (left > 0 || width < sourceWidth || top > 0 || height < sourceHeight) {
// image.crop(left, top, width, height)
// }

// image.grayscale()
}

public getRow(y: number /*int*/, row: Uint8ClampedArray): Uint8ClampedArray {
if (y < 0 || y >= this.image.getHeight()) {
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}

public getRow(y: number /*int*/, row: Uint8ClampedArray): Uint8ClampedArray {
if (y < 0 || y >= this.image.getHeight()) {
throw new IllegalArgumentException('Requested row is outside the image: ' + y);
}
const width: number /*int*/ = this.image.getWidth();
if (row === null || row.length < width) {
row = new Uint8ClampedArray(width); /*Int8Array(width)*/
}
// The underlying raster of image consists of bytes with the luminance values
this.image.getRow(y, row);
return row;
}

public getMatrix(): Uint8ClampedArray {
return this.image.getMatrix();
}

public isCropSupported(): boolean {
return true;
}

public crop(left: number /*int*/, top: number /*int*/, width: number /*int*/, height: number /*int*/): LuminanceSource {
super.crop(left, top, width, height);
return this;
}

/**
* This is always true, since the image is a gray-scale image.
*
* @return true
*/
public isRotateSupported(): boolean {
return true;
}

public rotateCounterClockwise(): LuminanceSource {
// this.image.rotate(-90)
// TYPESCRIPTPORT: not used for tests, see AbstractBlackBox.spec, SharpImage.loadWithRotations
return this;
}

public rotateCounterClockwise45(): LuminanceSource {
// this.image.rotate(-45)
// TYPESCRIPTPORT: not used for tests, see AbstractBlackBox.spec, SharpImage.loadWithRotations
return this;
}

public invert(): LuminanceSource {
return new InvertedLuminanceSource(this);
const width: number /*int*/ = this.image.getWidth();
if (row === null || row.length < width) {
row = new Uint8ClampedArray(width); /*Int8Array(width)*/
}
// The underlying raster of image consists of bytes with the luminance values
this.image.getRow(y, row);
return row;
}

public getMatrix(): Uint8ClampedArray {
return this.image.getMatrix();
}

public isCropSupported(): boolean {
return true;
}

public crop(left: number /*int*/, top: number /*int*/, width: number /*int*/, height: number /*int*/): LuminanceSource {
super.crop(left, top, width, height);
return this;
}

/**
* This is always true, since the image is a gray-scale image.
*
* @return true
*/
public isRotateSupported(): boolean {
return true;
}

public rotateCounterClockwise(): LuminanceSource {
// this.image.rotate(-90)
// TYPESCRIPTPORT: not used for tests, see AbstractBlackBox.spec, SharpImage.loadWithRotations
return this;
}

public rotateCounterClockwise45(): LuminanceSource {
// this.image.rotate(-45)
// TYPESCRIPTPORT: not used for tests, see AbstractBlackBox.spec, SharpImage.loadWithRotations
return this;
}

public invert(): LuminanceSource {
return new InvertedLuminanceSource(this);
}

}
6 changes: 3 additions & 3 deletions src/test/core/aztec/AztecBlackBox1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@
// package com.google.zxing.aztec;

// import com.google.zxing.BarcodeFormat;
import BarcodeFormat from '../../../core/BarcodeFormat';
import { BarcodeFormat } from '@zxing/library';
// import com.google.zxing.common.AbstractBlackBoxTestCase;
import AbstractBlackBoxSpec from '../common/AbstractBlackBox';

import AztecReader from '../../../core/aztec/AztecReader';
import { AztecCodeReader } from '@zxing/library';

/**
* @author David Olivier
*/
export /*public final*/ class AztecBlackBox1TestCase extends AbstractBlackBoxSpec {

public constructor() {
super('src/test/resources/blackbox/aztec-1', new AztecReader(), BarcodeFormat.AZTEC);
super('src/test/resources/blackbox/aztec-1', new AztecCodeReader(), BarcodeFormat.AZTEC);
this.addTest(13, 13, 0.0);
this.addTest(13, 13, 90.0);
this.addTest(13, 13, 180.0);
Expand Down
Loading

0 comments on commit 37f2a4f

Please sign in to comment.