Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@barcode-bakery/barcode-common

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@barcode-bakery/barcode-common - npm Package Compare versions

Comparing version 2.0.1 to 3.0.0-alpha.2

dist/.vite/manifest.json

2

dist/BCGArgumentException.d.ts

@@ -6,3 +6,3 @@ /*!

declare class BCGArgumentException extends Error {
param?: string | undefined;
readonly param?: string | undefined;
/**

@@ -9,0 +9,0 @@ * Constructor with specific message for a parameter.

@@ -1,8 +0,5 @@

/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import { BCGLabel } from './BCGLabel';
import { BCGColor } from './BCGColor';
import { BCGLabel } from './BCGLabel';
import { Surface } from './draw';
import * as draw from './draw';
/**

@@ -106,3 +103,3 @@ * Constructor.

*/
abstract draw(image: Surface): void;
abstract draw(image: draw.Surface): void;
/**

@@ -117,3 +114,3 @@ * Returns the maximal size of a barcode.

*/
getDimension(width: number, height: number): [number, number];
getDimension(width: number, height: number, createSurface?: draw.CreateSurface): [number, number];
/**

@@ -171,3 +168,3 @@ * Gets the X offset.

*/
protected drawText(image: Surface, x1: number, y1: number, x2: number, y2: number): void;
protected drawText(image: draw.Surface, x1: number, y1: number, x2: number, y2: number): void;
/**

@@ -181,3 +178,3 @@ * Draws 1 pixel on the resource at a specific position with a determined color.

*/
protected drawPixel(image: Surface, x: number, y: number, color?: number): void;
protected drawPixel(image: draw.Surface, x: number, y: number, color?: number): void;
/**

@@ -193,3 +190,3 @@ * Draws an empty rectangle on the resource at a specific position with a determined color.

*/
protected drawRectangle(image: Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
protected drawRectangle(image: draw.Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
/**

@@ -205,3 +202,3 @@ * Draws a filled rectangle on the resource at a specific position with a determined color.

*/
protected drawFilledRectangle(image: Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
protected drawFilledRectangle(image: draw.Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
/**

@@ -214,3 +211,3 @@ * Allocates the color based on the integer.

*/
protected getColor(image: Surface, color: number): {
protected getColor(image: draw.Surface, color: number): {
r: number;

@@ -217,0 +214,0 @@ g: number;

@@ -0,5 +1,6 @@

import { BCGLabel } from './BCGLabel';
import { BCGFont } from './BCGFont';
import { BCGBarcode } from './BCGBarcode';
import { BCGFont } from './BCGFont';
import { BCGLabel } from './BCGLabel';
import { Surface } from './draw';
import * as draw from './draw';
declare abstract class BCGBarcode1D extends BCGBarcode {

@@ -119,3 +120,3 @@ /**

*/
getDimension(width: number, height: number): [number, number];
getDimension(width: number, height: number, createSurface?: draw.CreateSurface): [number, number];
/**

@@ -131,3 +132,3 @@ * Returns the maximal size of a barcode.

*/
get1DDimension(width: number, height: number): [number, number];
get1DDimension(width: number, height: number, createSurface?: draw.CreateSurface): [number, number];
/**

@@ -163,3 +164,3 @@ * Adds the default label.

*/
protected drawChar(image: Surface, code: string, startBar?: boolean): void;
protected drawChar(image: draw.Surface, code: string, startBar?: boolean): void;
/**

@@ -171,3 +172,3 @@ * Draws a Bar of color depending of the resolution.

*/
protected drawSingleBar(image: Surface, color: number): void;
protected drawSingleBar(image: draw.Surface, color: number): void;
/**

@@ -174,0 +175,0 @@ * Moving the pointer right to write a bar.

import { BCGBarcode } from './BCGBarcode';
import { Surface } from './draw';
import * as draw from './draw';
/**

@@ -25,3 +26,3 @@ * Constructor.

*/
getDimension(width: number, height: number): [number, number];
getDimension(width: number, height: number, createSurface?: draw.CreateSurface): [number, number];
/**

@@ -53,3 +54,3 @@ * Sets the scale of the barcode in pixel for X.

*/
protected drawText(image: Surface, x1: number, y1: number, x2: number, y2: number): void;
protected drawText(image: draw.Surface, x1: number, y1: number, x2: number, y2: number): void;
/**

@@ -63,3 +64,3 @@ * Draws 1 pixel on the resource at a specific position with a determined color.

*/
protected drawPixel(image: Surface, x: number, y: number, color?: number): void;
protected drawPixel(image: draw.Surface, x: number, y: number, color?: number): void;
/**

@@ -75,3 +76,3 @@ * Draws an empty rectangle on the resource at a specific position with a determined color.

*/
protected drawRectangle(image: Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
protected drawRectangle(image: draw.Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
/**

@@ -87,4 +88,4 @@ * Draws a filled rectangle on the resource at a specific position with a determined color.

*/
protected drawFilledRectangle(image: Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
protected drawFilledRectangle(image: draw.Surface, x1: number, y1: number, x2: number, y2: number, color?: number): void;
}
export { BCGBarcode2D };

@@ -1,6 +0,3 @@

/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import { Surface } from './draw';
/**

@@ -7,0 +4,0 @@ * Holds Color in RGB Format.

@@ -0,0 +0,0 @@ /*!

@@ -0,0 +0,0 @@ /*!

@@ -1,18 +0,26 @@

/// <reference types="node" />
/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import { Surface } from './draw';
import { BCGColor } from './BCGColor';
import { BCGBarcode } from './BCGBarcode';
import { BCGColor } from './BCGColor';
export interface BCGDrawingOptions {
/**
* By setting to true, the owner of the surface is responsible to resize it correctly before drawing.
* Otherwise, the surface will not be correct.
* This defaults to false.
*/
skipResizingSurface?: boolean;
/**
* By setting to true, if an exception happens, it will be thrown.
* Otherwise, it will be drawn.
* The canvas will be resized accordingly, regardless of the @see BCGDrawingOptions.skipResizingSurface setting.
* This defaults to false.
*/
throwException?: boolean;
}
declare class BCGDrawing {
private w;
private h;
private image;
private readonly surface?;
private readonly createSurface;
private dpi;
private rotateDegree;
private barcode;
private exceptionToDraw;
private color;
private backgroundColor;
/**

@@ -24,22 +32,11 @@ * Creates a drawing surface by indicating its background color.

*/
constructor(barcode?: BCGBarcode | null, color?: BCGColor | null);
constructor(surface: Surface, color?: BCGColor | null);
constructor(createSurface: (width: number, height: number) => Surface, color?: BCGColor | null);
/**
* Gets the image resource.
*
* @return The surface abstraction where the barcode is drawn
* @return The surface abstraction where the barcode is drawn.
*/
getImage(): Surface | null;
/**
* Sets the image resource.
*
* @param image The surface
*/
setImage(image: Surface): void;
/**
* Gets barcode for drawing.
*
* @return The barcode.
*/
getBarcode(): BCGBarcode | null;
/**
* Gets the DPI for supported filetype.

@@ -68,14 +65,6 @@ *

setRotationAngle(degree: number | string): void;
toBuffer(format: BCGDrawing.ImageFormat, callback?: (err: Error | null, data: Buffer) => void): Buffer;
toBufferSync(format: BCGDrawing.ImageFormat): Buffer;
save(fileName: string, callback?: (err: NodeJS.ErrnoException) => void): void;
save(fileName: string, format: BCGDrawing.ImageFormat, callback?: (err: NodeJS.ErrnoException) => void): void;
draw(barcode: BCGBarcode, options?: BCGDrawingOptions): void;
private changeSurfaceSize;
private prepareSurface;
/**
* Draws the barcode in a file asynchronously
*
* @param fileName The file name.
* @param format The image format.
*/
saveSync(fileName: string, format: BCGDrawing.ImageFormat): void;
/**
* Writes the Error on the picture.

@@ -85,8 +74,3 @@ *

*/
drawException(exception: Error): void;
private draw;
/**
* Init Image and color background.
*/
private init;
drawException(exception: unknown): void;
}

@@ -93,0 +77,0 @@ declare namespace BCGDrawing {

import { BCGColor } from './BCGColor';
import * as draw from './draw';

@@ -50,5 +51,5 @@ declare class BCGFont {

*
* @param backgroundColor The background color.;
* @param _backgroundColor The background color.;
*/
setBackgroundColor(backgroundColor: BCGColor | null): void;
setBackgroundColor(_backgroundColor: BCGColor | null): void;
/**

@@ -71,3 +72,3 @@ * Gets the foreground color.

*/
getDimension(): [number, number];
getDimension(createSurface: draw.CreateSurface): [number, number];
/**

@@ -74,0 +75,0 @@ * Draws the text on the image at a specific position.

@@ -0,4 +1,5 @@

import { BCGColor } from './BCGColor';
import { BCGFont } from './BCGFont';
import { BCGColor } from './BCGColor';
import { Surface } from './draw';
import * as draw from './draw';
declare class BCGLabel {

@@ -138,3 +139,3 @@ private font;

*/
getDimension(): [number, number];
getDimension(createSurface: draw.CreateSurface): [number, number];
/**

@@ -152,3 +153,3 @@ * Draws the text.

*/
draw(image: Surface, x1: number, y1: number, x2: number, y2: number): void;
draw(image: draw.Surface, x1: number, y1: number, x2: number, y2: number): void;
}

@@ -155,0 +156,0 @@ declare namespace BCGLabel {

@@ -0,0 +0,0 @@ /*!

@@ -1,10 +0,73 @@

/// <reference types="node" />
/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import canvas from 'canvas';
export declare type Surface = canvas.CanvasRenderingContext2D;
export declare function imagecreatetruecolor(width: number, height: number, type?: 'pdf' | 'svg'): Surface;
export declare function imagecolortransparent(image: Surface, allocated: {
interface InternalCanvasRenderingContext2D {
readonly canvas: {
width: number;
height: number;
};
}
interface InternalCanvasRect {
fillRect(x: number, y: number, w: number, h: number): void;
}
interface InternalCanvasDrawPath {
/** [MDN Reference](https://developer.mozilla.org/docs/Web/API/CanvasRenderingContext2D/beginPath) */
beginPath(): void;
}
interface InternalCanvasPath {
ellipse(x: number, y: number, radiusX: number, radiusY: number, rotation: number, startAngle: number, endAngle: number, counterclockwise?: boolean): void;
}
type InternalCanvasFillRule = 'evenodd' | 'nonzero';
interface InternalCanvasDrawPath {
fill(fillRule?: InternalCanvasFillRule): void;
}
interface InternalCanvasState {
restore(): void;
save(): void;
}
interface InternalCanvasTransform {
rotate(angle: number): void;
translate(x: number, y: number): void;
}
interface InternalCanvasText {
measureText(text: string): TextMetrics;
fillText(text: string, x: number, y: number, maxWidth?: number): void;
}
interface InternalCanvasGradient {
addColorStop(offset: number, color: string): void;
}
interface InternalDOMMatrix2DInit {
a?: number;
b?: number;
c?: number;
d?: number;
e?: number;
f?: number;
m11?: number;
m12?: number;
m21?: number;
m22?: number;
m41?: number;
m42?: number;
}
interface InternalCanvasPattern {
setTransform(transform?: InternalDOMMatrix2DInit): void;
}
interface InternalCanvasFillStrokeStyles {
fillStyle: string | InternalCanvasGradient | InternalCanvasPattern;
}
interface InternalCanvasTextDrawingStyles {
font: string;
}
export interface TextMetrics {
readonly actualBoundingBoxAscent: number;
readonly actualBoundingBoxDescent: number;
readonly actualBoundingBoxLeft: number;
readonly actualBoundingBoxRight: number;
}
type InternalCanvasContext2D = InternalCanvasRenderingContext2D & InternalCanvasRect & InternalCanvasDrawPath & InternalCanvasPath & InternalCanvasDrawPath & InternalCanvasState & InternalCanvasTransform & InternalCanvasText & InternalCanvasFillStrokeStyles & InternalCanvasTextDrawingStyles;
export type CreateSurface = (width: number, height: number) => Surface;
export type Surface = {
context: InternalCanvasContext2D;
createSurface: CreateSurface;
};
export declare function imagecreatetruecolor(create: () => Surface): Surface;
export declare function imagecolortransparent(_image: Surface, _allocated: {
r: number;

@@ -18,3 +81,3 @@ g: number;

};
export declare function imagedestroy(image: Surface | null): void;
export declare function imagedestroy(_image: Surface | null): void;
export declare function imagesx(image: Surface): number;

@@ -51,14 +114,3 @@ export declare function imagesy(image: Surface): number;

setDPI(dpi: number | string | null): void;
abstract toFile(fileName: string, callback?: (err: NodeJS.ErrnoException) => void): void;
abstract toBuffer(callback?: (err: Error | null, data: Buffer) => void): Buffer;
}
export declare class DrawBasic extends Draw {
constructor(image: Surface);
toFile(fileName: string, callback?: (err: NodeJS.ErrnoException) => void): void;
toBuffer(callback?: (err: Error | null, data: Buffer) => void): Buffer;
}
export declare class DrawPNG extends Draw {
constructor(image: Surface);
toFile(fileName: string, callback?: (err: NodeJS.ErrnoException) => void): void;
toBuffer(callback?: (err: Error | null, data: Buffer) => void): Buffer;
}
export {};

@@ -1,18 +0,15 @@

/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import { BCGParseException } from './BCGParseException';
import { BCGLabel } from './BCGLabel';
import { BCGFont } from './BCGFont';
import { BCGDrawing } from './BCGDrawing';
import { BCGDrawException } from './BCGDrawException';
import { BCGColor } from './BCGColor';
import { BCGDataInput } from './BCGDataInput';
import { BCGBarcode2D } from './BCGBarcode2D';
import { BCGBarcode1D } from './BCGBarcode1D';
import { BCGBarcode } from './BCGBarcode';
import { BCGArgumentException } from './BCGArgumentException';
import { BCGBarcode } from './BCGBarcode';
import { BCGBarcode1D } from './BCGBarcode1D';
import { BCGBarcode2D } from './BCGBarcode2D';
import { BCGDataInput } from './BCGDataInput';
import { BCGColor } from './BCGColor';
import { BCGDrawException } from './BCGDrawException';
import * as draw from './draw';
import { BCGDrawing } from './BCGDrawing';
import { BCGFont } from './BCGFont';
import { BCGLabel } from './BCGLabel';
import { BCGParseException } from './BCGParseException';
import * as Utility from './Utility';
export { BCGArgumentException, BCGBarcode, BCGBarcode1D, BCGBarcode2D, BCGDataInput, BCGColor, BCGDrawException, BCGDrawing, BCGFont, BCGLabel, BCGParseException, Utility, draw };

@@ -1,6 +0,3 @@

/*!
* Copyright (C) Jean-Sebastien Goupil
* http://www.barcodebakery.com
*/
import { Surface } from './draw';
export declare function arraySearch(arr: string[], val: string): number;

@@ -18,6 +15,3 @@ export declare function substrCount(haystack: string, needle: string): number;

export declare function strrev(str: string): string;
export declare function clone<T>(obj: T & {
[key: string]: any;
clone?: () => T;
}): T;
export declare const clone: typeof structuredClone;
export declare function arraySum(array: number[]): number;

@@ -24,0 +18,0 @@ export declare function isInt(num: number): boolean;

{
"name": "@barcode-bakery/barcode-common",
"version": "2.0.1",
"description": "Base code for generating barcode with the Barcode Bakery library. See barcode-bakery-1d.",
"repository": "git://github.com/barcode-bakery/barcode-nodejs-common",
"author": {
"name": "Jean-Sébastien Goupil",
"email": "contact@barcodebakery.com"
},
"license": "See LICENSE.MD",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"files": [
"/dist"
],
"dependencies": {
"@types/node": "^7.0.5",
"canvas": "^2"
},
"devDependencies": {
"@tsconfig/node14": "^1.0.0",
"typescript": "^4.2.4"
}
"name": "@barcode-bakery/barcode-common",
"version": "3.0.0-alpha.2",
"description": "Base code for generating barcode with the Barcode Bakery library. See barcode-bakery-1d.",
"type": "module",
"repository": "git://github.com/barcode-bakery/barcode-ts-common",
"homepage": "https://www.barcodebakery.com",
"author": {
"name": "Jean-Sébastien Goupil",
"email": "contact@barcodebakery.com"
},
"scripts": {
"prepublishOnly": "vite build",
"build": "vite build",
"lint": "eslint"
},
"license": "See LICENSE.MD",
"files": [
"/dist"
],
"types": "dist/index.d.ts",
"main": "dist/barcode-common.umd.cjs",
"module": "dist/barcode-common.js",
"devDependencies": {
"@types/eslint": "^8.56.10",
"@types/node": "17.0.29",
"@typescript-eslint/eslint-plugin": "^7.7.1",
"@typescript-eslint/parser": "^7.7.1",
"eslint": "^9.1.1",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.1.3",
"globals": "^15.0.0",
"prettier": "^3.2.5",
"typescript": "^5",
"vite": "^5.2.0",
"vite-plugin-dts": "^3.9.0"
}
}

@@ -5,3 +5,3 @@ <p align="center"><a href="https://www.barcodebakery.com" target="_blank">

[Barcode Bakery][1] is library written in Node.js, [.NET Standard][2] and [PHP][3] which allows you to generate barcodes on the fly on your server for displaying or saving.
[Barcode Bakery][1] is a library written in Node.js, [.NET Standard][2] and [PHP][3] which allows you to generate barcodes on the fly on your server for displaying or saving.

@@ -8,0 +8,0 @@ This is the common base for generating all barcode types.

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc