Skip to content

Commit 0701513

Browse files
committed
Updates to support esbuild, issue #298
1 parent e8483bb commit 0701513

11 files changed

+62
-194
lines changed

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ found at the end of this document. Barcode images are generated as png (node-js
1111

1212
## Status
1313

14-
* Current bwip-js version is 3.4.4 (2023-07-27)
14+
* Current bwip-js version is 3.4.5 (2023-08-01)
1515
* Current BWIPP version is 2023-04-03
1616
* Node.js compatibility: 0.12+
1717
* Browser compatibility: Edge, Firefox, Chrome

dist/bwip-js-min.js

+4-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/bwip-js-node.js

+8-45
Original file line numberDiff line numberDiff line change
@@ -916,48 +916,6 @@ function bwipp_processoptions() {
916916
}
917917
}
918918

919-
// DEBUG-BEGIN
920-
function $stack() {
921-
console.log('[[[');
922-
for (var i = $j - 1; i >= 0; i--) {
923-
console.log(tostring($k[i]));
924-
}
925-
console.log(']]]');
926-
927-
function tostring(v) {
928-
// null can be mis-typed - get it out of the way
929-
if (v === null) {
930-
return 'null';
931-
} else if (v === undefined) {
932-
return '<undefined>';
933-
} else if (v instanceof Array) {
934-
var s = '<array,' + v.o + ',' + v.length + '>[';
935-
for (var j = v.o, a = v.b, l = v.length + v.o; j < l; j++) {
936-
s += (j == v.o ? '' : ',') + tostring(a[j]);
937-
}
938-
return s + ']';
939-
} else if (v instanceof Uint8Array) {
940-
return '(' + $z[v] + ')';
941-
} else if (v instanceof Map) {
942-
var s = '<<';
943-
for (var elt of v) {
944-
s += (s.length == 2 ? '' : ',') + elt[0] + ':' + tostring(elt[1]);
945-
}
946-
return s + '>>';
947-
} else if (typeof v === 'object') {
948-
var s = '<<';
949-
for (var id in v) {
950-
s += (s.length == 2 ? '' : ',') + id + ':' + tostring(v[id]);
951-
}
952-
return s + '>>';
953-
} else if (typeof v === 'string') {
954-
return '"' + v + '"';
955-
} else {
956-
return '' + v;
957-
}
958-
}
959-
}
960-
// DEBUG-END
961919
function bwipp_parseinput() {
962920
var $1 = Object.create(bwipp_parseinput.$ctx || (bwipp_parseinput.$ctx = {})); //#200
963921
$1.fncvals = $k[--$j]; //#204
@@ -41536,6 +41494,12 @@ var FontLib = (function() {
4153641494
}
4153741495
})();
4153841496

41497+
// This is needed to make the default exports traceable by esbuild
41498+
// during its tree shaking phase. See issue #298.
41499+
function LoadFont() {
41500+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
41501+
}
41502+
4153941503
// bwip-js/stb_trutype.js
4154041504
//
4154141505
// JavaScript implementation of stb_truetype.h @ https://github.com/nothings/stb.
@@ -43459,9 +43423,8 @@ FontLib.loadFont("OCR-B", 96, 100, "AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYA
4345943423
module.exports = {
4346043424
// The public interface
4346143425
request:Request, toBuffer:ToBuffer, render:Render, raw:ToRaw,
43462-
fixupOptions:FixupOptions,
43463-
loadFont:FontLib.loadFont,
43464-
BWIPJS_VERSION:'3.4.4 (2023-07-27)',
43426+
fixupOptions:FixupOptions, loadFont:LoadFont,
43427+
BWIPJS_VERSION:'3.4.5 (2023-08-01)',
4346543428
BWIPP_VERSION:BWIPP_VERSION,
4346643429
// Internals
4346743430
BWIPJS:BWIPJS, STBTT:STBTT, FontLib:FontLib,

dist/bwip-js-node.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1867,6 +1867,12 @@ var FontLib = (function() {
18671867
}
18681868
})();
18691869

1870+
// This is needed to make the default exports traceable by esbuild
1871+
// during its tree shaking phase. See issue #298.
1872+
function LoadFont() {
1873+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
1874+
}
1875+
18701876
// bwip-js/stb_trutype.js
18711877
//
18721878
// JavaScript implementation of stb_truetype.h @ https://github.com/nothings/stb.
@@ -3898,12 +3904,13 @@ export function upca(opts,cvs) { return _ToBuffer(bwipp_upca,opts,cvs); };
38983904
export function upcacomposite(opts,cvs) { return _ToBuffer(bwipp_upcacomposite,opts,cvs); };
38993905
export function upce(opts,cvs) { return _ToBuffer(bwipp_upce,opts,cvs); };
39003906
export function upcecomposite(opts,cvs) { return _ToBuffer(bwipp_upcecomposite,opts,cvs); };
3907+
const BWIPJS_VERSION = '3.4.5 (2023-08-01)';
3908+
export { BWIPJS_VERSION, BWIPP_VERSION, LoadFont as loadFont };
39013909
export default {
39023910
// The public interface
39033911
request:Request, toBuffer:ToBuffer, render:Render, raw:ToRaw,
3904-
fixupOptions : FixupOptions,
3905-
loadFont : FontLib.loadFont,
3906-
BWIPJS_VERSION : '3.4.4 (2023-07-27)',
3912+
fixupOptions : FixupOptions, loadFont : LoadFont,
3913+
BWIPJS_VERSION : BWIPJS_VERSION,
39073914
BWIPP_VERSION : BWIPP_VERSION,
39083915
// Internals
39093916
BWIPJS, STBTT, FontLib, DrawingBuiltin, DrawingZlibPng,

dist/bwip-js-rn.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1852,6 +1852,12 @@ var FontLib = (function() {
18521852
}
18531853
})();
18541854

1855+
// This is needed to make the default exports traceable by esbuild
1856+
// during its tree shaking phase. See issue #298.
1857+
function LoadFont() {
1858+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
1859+
}
1860+
18551861
// bwip-js/stb_trutype.js
18561862
//
18571863
// JavaScript implementation of stb_truetype.h @ https://github.com/nothings/stb.
@@ -3883,12 +3889,13 @@ export function upca(opts) { return _ToDataURL(bwipp_upca,opts); };
38833889
export function upcacomposite(opts) { return _ToDataURL(bwipp_upcacomposite,opts); };
38843890
export function upce(opts) { return _ToDataURL(bwipp_upce,opts); };
38853891
export function upcecomposite(opts) { return _ToDataURL(bwipp_upcecomposite,opts); };
3892+
const BWIPJS_VERSION = '3.4.5 (2023-08-01)';
3893+
export { BWIPJS_VERSION, BWIPP_VERSION, LoadFont as loadFont };
38863894
export default {
38873895
// The public interface
38883896
toDataURL:ToDataURL, render:Render, raw:ToRaw,
3889-
fixupOptions : FixupOptions,
3890-
loadFont : FontLib.loadFont,
3891-
BWIPJS_VERSION : '3.4.4 (2023-07-27)',
3897+
fixupOptions : FixupOptions, loadFont : LoadFont,
3898+
BWIPJS_VERSION : BWIPJS_VERSION,
38923899
BWIPP_VERSION : BWIPP_VERSION,
38933900
// Internals
38943901
BWIPJS, STBTT, FontLib, DrawingBuiltin, DrawingZlibPng,

dist/bwip-js.js

+8-45
Original file line numberDiff line numberDiff line change
@@ -897,48 +897,6 @@ function bwipp_processoptions() {
897897
}
898898
}
899899

900-
// DEBUG-BEGIN
901-
function $stack() {
902-
console.log('[[[');
903-
for (var i = $j - 1; i >= 0; i--) {
904-
console.log(tostring($k[i]));
905-
}
906-
console.log(']]]');
907-
908-
function tostring(v) {
909-
// null can be mis-typed - get it out of the way
910-
if (v === null) {
911-
return 'null';
912-
} else if (v === undefined) {
913-
return '<undefined>';
914-
} else if (v instanceof Array) {
915-
var s = '<array,' + v.o + ',' + v.length + '>[';
916-
for (var j = v.o, a = v.b, l = v.length + v.o; j < l; j++) {
917-
s += (j == v.o ? '' : ',') + tostring(a[j]);
918-
}
919-
return s + ']';
920-
} else if (v instanceof Uint8Array) {
921-
return '(' + $z[v] + ')';
922-
} else if (v instanceof Map) {
923-
var s = '<<';
924-
for (var elt of v) {
925-
s += (s.length == 2 ? '' : ',') + elt[0] + ':' + tostring(elt[1]);
926-
}
927-
return s + '>>';
928-
} else if (typeof v === 'object') {
929-
var s = '<<';
930-
for (var id in v) {
931-
s += (s.length == 2 ? '' : ',') + id + ':' + tostring(v[id]);
932-
}
933-
return s + '>>';
934-
} else if (typeof v === 'string') {
935-
return '"' + v + '"';
936-
} else {
937-
return '' + v;
938-
}
939-
}
940-
}
941-
// DEBUG-END
942900
function bwipp_parseinput() {
943901
var $1 = Object.create(bwipp_parseinput.$ctx || (bwipp_parseinput.$ctx = {})); //#200
944902
$1.fncvals = $k[--$j]; //#204
@@ -41370,6 +41328,12 @@ var FontLib = (function() {
4137041328
}
4137141329
})();
4137241330

41331+
// This is needed to make the default exports traceable by esbuild
41332+
// during its tree shaking phase. See issue #298.
41333+
function LoadFont() {
41334+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
41335+
}
41336+
4137341337
// bwip-js/stb_trutype.js
4137441338
//
4137541339
// JavaScript implementation of stb_truetype.h @ https://github.com/nothings/stb.
@@ -43298,9 +43262,8 @@ FontLib.loadFont("OCR-B", 96, 100, "AAEAAAAPAIAAAwBwRkZUTXxHn14AADmUAAAAHEdERUYA
4329843262
return {
4329943263
// The public interface
4330043264
toCanvas:ToCanvas, render:Render, raw:ToRaw,
43301-
fixupOptions:FixupOptions,
43302-
loadFont:FontLib.loadFont,
43303-
BWIPJS_VERSION:'3.4.4 (2023-07-27)',
43265+
fixupOptions:FixupOptions, loadFont:LoadFont,
43266+
BWIPJS_VERSION:'3.4.5 (2023-08-01)',
4330443267
BWIPP_VERSION:BWIPP_VERSION,
4330543268
// Internals
4330643269
BWIPJS:BWIPJS, STBTT:STBTT, FontLib:FontLib,

dist/bwip-js.mjs

+10-3
Original file line numberDiff line numberDiff line change
@@ -1692,6 +1692,12 @@ var FontLib = (function() {
16921692
}
16931693
})();
16941694

1695+
// This is needed to make the default exports traceable by esbuild
1696+
// during its tree shaking phase. See issue #298.
1697+
function LoadFont() {
1698+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
1699+
}
1700+
16951701
// bwip-js/stb_trutype.js
16961702
//
16971703
// JavaScript implementation of stb_truetype.h @ https://github.com/nothings/stb.
@@ -3728,12 +3734,13 @@ export function upca(opts,cvs) { return _ToCanvas(bwipp_upca,opts,cvs); };
37283734
export function upcacomposite(opts,cvs) { return _ToCanvas(bwipp_upcacomposite,opts,cvs); };
37293735
export function upce(opts,cvs) { return _ToCanvas(bwipp_upce,opts,cvs); };
37303736
export function upcecomposite(opts,cvs) { return _ToCanvas(bwipp_upcecomposite,opts,cvs); };
3737+
const BWIPJS_VERSION = '3.4.5 (2023-08-01)';
3738+
export { BWIPJS_VERSION, BWIPP_VERSION, LoadFont as loadFont };
37313739
export default {
37323740
// The public interface
37333741
toCanvas : ToCanvas, render : Render, raw : ToRaw,
3734-
fixupOptions : FixupOptions,
3735-
loadFont : FontLib.loadFont,
3736-
BWIPJS_VERSION : '3.4.4 (2023-07-27)',
3742+
fixupOptions : FixupOptions, loadFont : LoadFont,
3743+
BWIPJS_VERSION : BWIPJS_VERSION,
37373744
BWIPP_VERSION : BWIPP_VERSION,
37383745
// Internals
37393746
BWIPJS, STBTT, FontLib, DrawingBuiltin, DrawingCanvas,

dist/bwipp.mjs

-42
Original file line numberDiff line numberDiff line change
@@ -660,48 +660,6 @@ function bwipp_processoptions() {
660660
}
661661
}
662662

663-
// DEBUG-BEGIN
664-
function $stack() {
665-
console.log('[[[');
666-
for (var i = $j - 1; i >= 0; i--) {
667-
console.log(tostring($k[i]));
668-
}
669-
console.log(']]]');
670-
671-
function tostring(v) {
672-
// null can be mis-typed - get it out of the way
673-
if (v === null) {
674-
return 'null';
675-
} else if (v === undefined) {
676-
return '<undefined>';
677-
} else if (v instanceof Array) {
678-
var s = '<array,' + v.o + ',' + v.length + '>[';
679-
for (var j = v.o, a = v.b, l = v.length + v.o; j < l; j++) {
680-
s += (j == v.o ? '' : ',') + tostring(a[j]);
681-
}
682-
return s + ']';
683-
} else if (v instanceof Uint8Array) {
684-
return '(' + $z[v] + ')';
685-
} else if (v instanceof Map) {
686-
var s = '<<';
687-
for (var elt of v) {
688-
s += (s.length == 2 ? '' : ',') + elt[0] + ':' + tostring(elt[1]);
689-
}
690-
return s + '>>';
691-
} else if (typeof v === 'object') {
692-
var s = '<<';
693-
for (var id in v) {
694-
s += (s.length == 2 ? '' : ',') + id + ':' + tostring(v[id]);
695-
}
696-
return s + '>>';
697-
} else if (typeof v === 'string') {
698-
return '"' + v + '"';
699-
} else {
700-
return '' + v;
701-
}
702-
}
703-
}
704-
// DEBUG-END
705663
function bwipp_parseinput() {
706664
var $1 = Object.create(bwipp_parseinput.$ctx || (bwipp_parseinput.$ctx = {})); //#200
707665
$1.fncvals = $k[--$j]; //#204

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,7 @@
11
{
22
"name": "bwip-js",
3-
"version": "3.4.4",
3+
"version": "3.4.5",
44
"description": "JavaScript barcode generator supporting over 100 types and standards.",
5-
"main": "./dist/bwip-js-node.js",
6-
"browser": "./dist/bwip-js.js",
75
"exports": {
86
"browser": {
97
"import": "./dist/bwip-js.mjs",
@@ -23,6 +21,8 @@
2321
"require": "./dist/bwip-js-node.js"
2422
}
2523
},
24+
"main": "./dist/bwip-js-node.js",
25+
"browser": "./dist/bwip-js.js",
2626
"react-native": "./dist/bwip-js-rn.mjs",
2727
"bin": {
2828
"bwip-js": "./bin/bwip-js.js"

src/bwipp.js

-42
Original file line numberDiff line numberDiff line change
@@ -628,48 +628,6 @@ function bwipp_processoptions() {
628628
}
629629
}
630630

631-
// DEBUG-BEGIN
632-
function $stack() {
633-
console.log('[[[');
634-
for (var i = $j - 1; i >= 0; i--) {
635-
console.log(tostring($k[i]));
636-
}
637-
console.log(']]]');
638-
639-
function tostring(v) {
640-
// null can be mis-typed - get it out of the way
641-
if (v === null) {
642-
return 'null';
643-
} else if (v === undefined) {
644-
return '<undefined>';
645-
} else if (v instanceof Array) {
646-
var s = '<array,' + v.o + ',' + v.length + '>[';
647-
for (var j = v.o, a = v.b, l = v.length + v.o; j < l; j++) {
648-
s += (j == v.o ? '' : ',') + tostring(a[j]);
649-
}
650-
return s + ']';
651-
} else if (v instanceof Uint8Array) {
652-
return '(' + $z[v] + ')';
653-
} else if (v instanceof Map) {
654-
var s = '<<';
655-
for (var elt of v) {
656-
s += (s.length == 2 ? '' : ',') + elt[0] + ':' + tostring(elt[1]);
657-
}
658-
return s + '>>';
659-
} else if (typeof v === 'object') {
660-
var s = '<<';
661-
for (var id in v) {
662-
s += (s.length == 2 ? '' : ',') + id + ':' + tostring(v[id]);
663-
}
664-
return s + '>>';
665-
} else if (typeof v === 'string') {
666-
return '"' + v + '"';
667-
} else {
668-
return '' + v;
669-
}
670-
}
671-
}
672-
// DEBUG-END
673631
function bwipp_parseinput() {
674632
var $1 = Object.create(bwipp_parseinput.$ctx || (bwipp_parseinput.$ctx = {})); //#200
675633
$1.fncvals = $k[--$j]; //#204

src/fontlib.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ var FontLib = (function() {
3737
multx = +arguments[2] || 100;
3838
data = arguments[3];
3939
} else {
40-
throw new Error("loadFont(): invalid number of arguments");
40+
throw new Error("bwipjs: loadFont: invalid number of arguments");
4141
}
4242

4343
var font = STBTT.InitFont(toUint8Array(data));
@@ -59,7 +59,7 @@ var FontLib = (function() {
5959
// Not supported by stbtt
6060
function monochrome(mono) {
6161
if (mono) {
62-
throw new Error('fontlib: monochrome not implemented');
62+
throw new Error('bwipjs: monochrome fonts not implemented');
6363
}
6464
}
6565

@@ -168,3 +168,9 @@ var FontLib = (function() {
168168
}
169169
})();
170170

171+
// This is needed to make the default exports traceable by esbuild
172+
// during its tree shaking phase. See issue #298.
173+
function LoadFont() {
174+
return FontLib.loadFont.apply(FontLib, Array.prototype.slice.call(arguments));
175+
}
176+

0 commit comments

Comments
 (0)