Barcode Generation
This commit is contained in:
@@ -24,6 +24,7 @@ def print_label(values):
|
||||
doc.customer = values["customer"]
|
||||
doc.batch = values["batch"]
|
||||
doc.qty = label["item_qty"]
|
||||
doc.information = label["information"]
|
||||
newdoc = doc.insert()
|
||||
|
||||
print_label_by_server("Label", newdoc.name, label["label_qty"], printer_setting[0],"Label", doc=None, no_letterhead=0, file_path=None)
|
||||
@@ -69,5 +70,4 @@ def print_label_by_server(doctype, name, qty, printer_setting, print_format=None
|
||||
|
||||
@frappe.whitelist()
|
||||
def get_associated_stockentry(workorder):
|
||||
return frappe.get_last_doc('Stock Entry', filters = {"work_order": "PRO-01530"})
|
||||
|
||||
return frappe.get_last_doc('Stock Entry', filters = {"work_order": workorder})
|
||||
@@ -178,3 +178,10 @@ user_data_fields = [
|
||||
# auth_hooks = [
|
||||
# "label_printing.auth.validate"
|
||||
# ]
|
||||
|
||||
jenv = {
|
||||
"methods": [
|
||||
"generateBarcode:label_printing.utils.barcode.generateBarcode",
|
||||
"get_code128_glyphs:label_printing.utils.barcode.generateBarcodeGlyphs"
|
||||
]
|
||||
}
|
||||
@@ -13,7 +13,8 @@
|
||||
"column_break_4",
|
||||
"delivery_date",
|
||||
"customer",
|
||||
"batch"
|
||||
"batch",
|
||||
"information"
|
||||
],
|
||||
"fields": [
|
||||
{
|
||||
@@ -54,11 +55,16 @@
|
||||
"fieldname": "qty",
|
||||
"fieldtype": "Int",
|
||||
"label": "Quantity"
|
||||
},
|
||||
{
|
||||
"fieldname": "information",
|
||||
"fieldtype": "Data",
|
||||
"label": "Information"
|
||||
}
|
||||
],
|
||||
"icon": "fa fa-tag",
|
||||
"links": [],
|
||||
"modified": "2022-01-19 12:08:40.613669",
|
||||
"modified": "2022-02-17 09:25:53.912471",
|
||||
"modified_by": "Administrator",
|
||||
"module": "Label Printing",
|
||||
"name": "Label",
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
!function(){"use strict";function e(e,a){var t;return frappe.call({method:"frappe.client.get",async:!1,args:{doctype:e,name:a},callback:function(e){e.message&&(t=e.message)}}),t}$(document).ready(function(){$(".dropdown-notifications").after('<li id="labels-toolbar" class="nav-item"><a class="nav-link label-printing-icon text-muted"><i class="fa fa-tag fa-lg" aria-hidden="true"></i></a></li>'),$("#labels-toolbar").click(function(a){!function(a){var t=a.view.cur_frm,l={doctype:"",docname:"",item_code:"",item_name:"",delivery_date:"",customer:"",batch:"",information:"",total_amount:0,labels:[{item_qty:0,label_qty:0}]};null!==t&&("Work Order"!==t.doctype&&"Item"!==t.doctype||t.docname&&(l.doctype=t.doctype,l.docname=t.docname));var i=new frappe.ui.Dialog({title:__("Print Labels"),fields:[{label:__("Reference Doctype"),options:["Work Order","Item"],fieldname:"doctype",fieldtype:"Select",default:l.doctype},{label:__("Get data"),fieldname:"get_data",fieldtype:"Button",click:function(){n()}},{fieldtype:"Column Break"},{label:__("Reference Docname"),fieldname:"docname",fieldtype:"Data",options:"doctype",default:l.docname},{fieldtype:"Section Break",label:__("Information")},{label:__("Item Code"),fieldname:"item_code",fieldtype:"Data"},{label:__("Item Name"),fieldname:"item_name",fieldtype:"Data"},{label:__("Delivery Date"),fieldname:"delivery_date",fieldtype:"Date"},{fieldtype:"Column Break"},{label:__("Customer"),fieldname:"customer",fieldtype:"Data"},{label:__("Batch"),fieldname:"batch",fieldtype:"Data"},{fieldtype:"Section Break",label:__("Labels")},{fieldname:"labels",fieldtype:"Table",cannot_add_rows:!1,in_place_edit:!0,data:l.labels,get_data:function(){return l.labels},fields:[{fieldtype:"Int",fieldname:"item_qty",in_list_view:1,label:__("Item Qty")},{label:__("Label Qty"),fieldname:"label_qty",in_list_view:1,fieldtype:"Int"}]}],primary_action_label:"Print",primary_action:function(e){l=e,frappe.call({method:"label_printing.api.print_label",args:{values:l},callback:function(e){200===e.message&&frappe.show_alert("Label printing successful",5)}}),i.hide()}});function n(){if((l=i.get_values()).doctype&&l.docname){var a=e(l.doctype,l.docname);if("Work Order"===l.doctype){var t=e("Item",a.production_item);if(frappe.call({method:"label_printing.api.get_associated_stockentry",async:!1,args:{workorder:l.docname},callback:function(e){e.message&&(l.batch=e.message.items[e.message.items.length-1].batch_no)}}),l.item_code=t.item_code,l.item_name=t.item_name,l.delivery_date=a.expected_delivery_date,l.labels[0].item_qty=a.qty,l.labels[0].label_qty=1,t.associated_company){var n=e("Customer",t.associated_company);n.short_name?l.customer=n.short_name:l.customer=t.associated_company}l.total_amount=a.qty,l.labels[0].qty_per_label=a.qty,i.fields_dict.labels.refresh()}else if("Item"===l.doctype){var o=e("Item",a.item_code);if(l.item_code=a.item_code,l.item_name=a.item_name,o.associated_company){var c=e("Customer",a.associated_company);c.short_name?l.customer=c.short_name:l.customer=a.associated_company}}i.set_values(l)}}n(),i.show(),i.fields_dict.doctype.$input.on("change",function(){i.fields_dict.docname.refresh()})}(a)})})}();
|
||||
!function(){"use strict";function e(e,a){var t;return frappe.call({method:"frappe.client.get",async:!1,args:{doctype:e,name:a},callback:function(e){e.message&&(t=e.message)}}),t}$(document).ready(function(){$(".dropdown-notifications").after('<li id="labels-toolbar" class="nav-item"><a class="nav-link label-printing-icon text-muted"><i class="fa fa-tag fa-lg" aria-hidden="true"></i></a></li>'),$("#labels-toolbar").click(function(a){!function(a){var t=a.view.cur_frm,l={doctype:"",docname:"",item_code:"",item_name:"",delivery_date:"",customer:"",batch:"",information:"",total_amount:0,labels:[{item_qty:0,label_qty:0}]};null!==t&&("Work Order"!==t.doctype&&"Item"!==t.doctype||t.docname&&(l.doctype=t.doctype,l.docname=t.docname));var i=new frappe.ui.Dialog({title:__("Print Labels"),fields:[{label:__("Reference Doctype"),options:["Work Order","Item"],fieldname:"doctype",fieldtype:"Select",default:l.doctype},{label:__("Get data"),fieldname:"get_data",fieldtype:"Button",click:function(){n()}},{fieldtype:"Column Break"},{label:__("Reference Docname"),fieldname:"docname",fieldtype:"Data",options:"doctype",default:l.docname},{fieldtype:"Section Break",label:__("Information")},{label:__("Item Code"),fieldname:"item_code",fieldtype:"Data"},{label:__("Item Name"),fieldname:"item_name",fieldtype:"Data"},{label:__("Delivery Date"),fieldname:"delivery_date",fieldtype:"Date"},{fieldtype:"Column Break"},{label:__("Customer"),fieldname:"customer",fieldtype:"Data"},{label:__("Batch"),fieldname:"batch",fieldtype:"Data"},{fieldtype:"Section Break",label:__("Labels")},{fieldname:"labels",fieldtype:"Table",cannot_add_rows:!1,in_place_edit:!0,data:l.labels,get_data:function(){return l.labels},fields:[{fieldtype:"Int",fieldname:"item_qty",in_list_view:1,label:__("Item Qty")},{label:__("Label Qty"),fieldname:"label_qty",in_list_view:1,fieldtype:"Int"},{fieldtype:"Data",fieldname:"information",in_list_view:1,label:__("Information")}]}],primary_action_label:"Print",primary_action:function(e){l=e,frappe.call({method:"label_printing.api.print_label",args:{values:l},callback:function(e){200===e.message&&frappe.show_alert("Label printing successful",5)}}),i.hide()}});function n(){if((l=i.get_values()).doctype&&l.docname){var a=e(l.doctype,l.docname);if("Work Order"===l.doctype){var t=e("Item",a.production_item);if(frappe.call({method:"label_printing.api.get_associated_stockentry",async:!1,args:{workorder:l.docname},callback:function(e){e.message&&(l.batch=e.message.items[e.message.items.length-1].batch_no)}}),l.item_code=t.item_code,l.item_name=t.item_name,l.delivery_date=a.expected_delivery_date,l.labels[0].item_qty=a.qty,l.labels[0].label_qty=1,t.associated_company){var n=e("Customer",t.associated_company);n.short_name?l.customer=n.short_name:l.customer=t.associated_company}l.total_amount=a.qty,l.labels[0].qty_per_label=a.qty,i.fields_dict.labels.refresh()}else if("Item"===l.doctype){var o=e("Item",a.item_code);if(l.item_code=a.item_code,l.item_name=a.item_name,o.associated_company){var c=e("Customer",a.associated_company);c.short_name?l.customer=c.short_name:l.customer=a.associated_company}}i.set_values(l)}}n(),i.show(),i.fields_dict.doctype.$input.on("change",function(){i.fields_dict.docname.refresh()})}(a)})})}();
|
||||
//# sourceMappingURL=label_printing.min.js.map
|
||||
|
||||
File diff suppressed because one or more lines are too long
@@ -41,7 +41,7 @@ function setupLabelsDialog(page) {
|
||||
title: __("Print Labels"),
|
||||
fields: [{
|
||||
label: __("Reference Doctype"),
|
||||
options: ['Work Order', 'Item'],
|
||||
options: ['Work Order', 'Item', 'Label'],
|
||||
fieldname: 'doctype',
|
||||
fieldtype: 'Select',
|
||||
default: fields.doctype,
|
||||
@@ -121,6 +121,12 @@ function setupLabelsDialog(page) {
|
||||
in_list_view: 1,
|
||||
fieldtype: 'Int'
|
||||
},
|
||||
{
|
||||
fieldtype: 'Data',
|
||||
fieldname: "information",
|
||||
in_list_view: 1,
|
||||
label: __('Information')
|
||||
},
|
||||
]
|
||||
},
|
||||
],
|
||||
@@ -203,7 +209,6 @@ function setupLabelsDialog(page) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
d.set_values(fields)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1 +1 @@
|
||||
/Volumes/development/frappe/frappe-bench/apps/label_printing/node_modules
|
||||
/home/frappe/frappe-bench/apps/label_printing/node_modules
|
||||
136
label_printing/utils/barcode.py
Normal file
136
label_printing/utils/barcode.py
Normal file
@@ -0,0 +1,136 @@
|
||||
import frappe
|
||||
from io import BytesIO
|
||||
from barcode import EAN13
|
||||
from barcode.writer import ImageWriter
|
||||
|
||||
@frappe.whitelist()
|
||||
def generateBarcode(string):
|
||||
rv = BytesIO()
|
||||
EAN13(str(100000902922), writer=ImageWriter()).write(rv)
|
||||
print(rv.decode('UTF-8'))
|
||||
|
||||
lookup = {
|
||||
" ": 0,
|
||||
"!": 1,
|
||||
'"': 2,
|
||||
"#": 3,
|
||||
"$": 4,
|
||||
"%": 5,
|
||||
"&": 6,
|
||||
"‘": 7,
|
||||
"(": 8,
|
||||
")": 9,
|
||||
"*": 10,
|
||||
"+": 11,
|
||||
",": 12,
|
||||
"-": 13,
|
||||
".": 14,
|
||||
"/": 15,
|
||||
"0": 16,
|
||||
"1": 17,
|
||||
"2": 18,
|
||||
"3": 19,
|
||||
"4": 20,
|
||||
"5": 21,
|
||||
"6": 22,
|
||||
"7": 23,
|
||||
"8": 24,
|
||||
"9": 25,
|
||||
":": 26,
|
||||
";": 27,
|
||||
"<": 28,
|
||||
"=": 29,
|
||||
">": 30,
|
||||
"?": 31,
|
||||
"@": 32,
|
||||
"A": 33,
|
||||
"B": 34,
|
||||
"C": 35,
|
||||
"D": 36,
|
||||
"E": 37,
|
||||
"F": 38,
|
||||
"G": 39,
|
||||
"H": 40,
|
||||
"I": 41,
|
||||
"J": 42,
|
||||
"K": 43,
|
||||
"L": 44,
|
||||
"M": 45,
|
||||
"N": 46,
|
||||
"O": 47,
|
||||
"P": 48,
|
||||
"Q": 49,
|
||||
"R": 50,
|
||||
"S": 51,
|
||||
"T": 52,
|
||||
"U": 53,
|
||||
"V": 54,
|
||||
"W": 55,
|
||||
"X": 56,
|
||||
"Y": 57,
|
||||
"Z": 58,
|
||||
"[": 59,
|
||||
"\\": 60,
|
||||
"]": 61,
|
||||
"^": 62,
|
||||
"_": 63,
|
||||
"`": 64,
|
||||
"a": 65,
|
||||
"b": 66,
|
||||
"c": 67,
|
||||
"d": 68,
|
||||
"e": 69,
|
||||
"f": 70,
|
||||
"g": 71,
|
||||
"h": 72,
|
||||
"i": 73,
|
||||
"j": 74,
|
||||
"k": 75,
|
||||
"l": 76,
|
||||
"m": 77,
|
||||
"n": 78,
|
||||
"o": 79,
|
||||
"p": 80,
|
||||
"q": 81,
|
||||
"r": 82,
|
||||
"s": 83,
|
||||
"t": 84,
|
||||
"u": 85,
|
||||
"v": 86,
|
||||
"w": 87,
|
||||
"x": 88,
|
||||
"y": 89,
|
||||
"z": 90,
|
||||
"{": 91,
|
||||
"|": 92,
|
||||
"}": 93,
|
||||
"~": 94,
|
||||
"Ã": 95,
|
||||
"Ä": 96,
|
||||
"Å": 97,
|
||||
"Æ": 98,
|
||||
"Ç": 99,
|
||||
"È": 100,
|
||||
"É": 101,
|
||||
"Ê": 102,
|
||||
"Ë": 103,
|
||||
"Ì": 104,
|
||||
"Í": 105
|
||||
}
|
||||
|
||||
|
||||
@frappe.whitelist()
|
||||
def generateBarcodeGlyphs(data):
|
||||
code = chr(204)
|
||||
checksum = 104
|
||||
|
||||
for i in range(len(data)):
|
||||
code += data[i]
|
||||
checksum += lookup[data[i]] * (i + 1)
|
||||
|
||||
code += list(lookup.keys())[list(lookup.values()).index(checksum % 103)]
|
||||
|
||||
# append stop
|
||||
code += chr(206)
|
||||
|
||||
return code
|
||||
1
node_modules/.bin/Barcode.js
generated
vendored
Symbolic link
1
node_modules/.bin/Barcode.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/Barcode.js
|
||||
1
node_modules/.bin/CODE128
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128
|
||||
1
node_modules/.bin/CODE128.js
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/CODE128.js
|
||||
1
node_modules/.bin/CODE128A.js
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128A.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/CODE128A.js
|
||||
1
node_modules/.bin/CODE128B.js
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128B.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/CODE128B.js
|
||||
1
node_modules/.bin/CODE128C.js
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128C.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/CODE128C.js
|
||||
1
node_modules/.bin/CODE128_AUTO.js
generated
vendored
Symbolic link
1
node_modules/.bin/CODE128_AUTO.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/CODE128_AUTO.js
|
||||
1
node_modules/.bin/CODE39
generated
vendored
Symbolic link
1
node_modules/.bin/CODE39
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE39
|
||||
1
node_modules/.bin/EAN.js
generated
vendored
Symbolic link
1
node_modules/.bin/EAN.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/EAN.js
|
||||
1
node_modules/.bin/EAN13.js
generated
vendored
Symbolic link
1
node_modules/.bin/EAN13.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/EAN13.js
|
||||
1
node_modules/.bin/EAN2.js
generated
vendored
Symbolic link
1
node_modules/.bin/EAN2.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/EAN2.js
|
||||
1
node_modules/.bin/EAN5.js
generated
vendored
Symbolic link
1
node_modules/.bin/EAN5.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/EAN5.js
|
||||
1
node_modules/.bin/EAN8.js
generated
vendored
Symbolic link
1
node_modules/.bin/EAN8.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/EAN8.js
|
||||
1
node_modules/.bin/EAN_UPC
generated
vendored
Symbolic link
1
node_modules/.bin/EAN_UPC
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC
|
||||
1
node_modules/.bin/ErrorHandler.js
generated
vendored
Symbolic link
1
node_modules/.bin/ErrorHandler.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/exceptions/ErrorHandler.js
|
||||
1
node_modules/.bin/GenericBarcode
generated
vendored
Symbolic link
1
node_modules/.bin/GenericBarcode
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/GenericBarcode
|
||||
1
node_modules/.bin/ITF
generated
vendored
Symbolic link
1
node_modules/.bin/ITF
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/ITF
|
||||
1
node_modules/.bin/ITF.js
generated
vendored
Symbolic link
1
node_modules/.bin/ITF.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/ITF/ITF.js
|
||||
1
node_modules/.bin/ITF14.js
generated
vendored
Symbolic link
1
node_modules/.bin/ITF14.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/ITF/ITF14.js
|
||||
1
node_modules/.bin/JsBarcode.js
generated
vendored
Symbolic link
1
node_modules/.bin/JsBarcode.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/JsBarcode.js
|
||||
1
node_modules/.bin/MSI
generated
vendored
Symbolic link
1
node_modules/.bin/MSI
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI
|
||||
1
node_modules/.bin/MSI.js
generated
vendored
Symbolic link
1
node_modules/.bin/MSI.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/MSI.js
|
||||
1
node_modules/.bin/MSI10.js
generated
vendored
Symbolic link
1
node_modules/.bin/MSI10.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/MSI10.js
|
||||
1
node_modules/.bin/MSI1010.js
generated
vendored
Symbolic link
1
node_modules/.bin/MSI1010.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/MSI1010.js
|
||||
1
node_modules/.bin/MSI11.js
generated
vendored
Symbolic link
1
node_modules/.bin/MSI11.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/MSI11.js
|
||||
1
node_modules/.bin/MSI1110.js
generated
vendored
Symbolic link
1
node_modules/.bin/MSI1110.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/MSI1110.js
|
||||
1
node_modules/.bin/UPC.js
generated
vendored
Symbolic link
1
node_modules/.bin/UPC.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/UPC.js
|
||||
1
node_modules/.bin/UPCE.js
generated
vendored
Symbolic link
1
node_modules/.bin/UPCE.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/UPCE.js
|
||||
1
node_modules/.bin/auto.js
generated
vendored
Symbolic link
1
node_modules/.bin/auto.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/CODE128/auto.js
|
||||
1
node_modules/.bin/barcodes
generated
vendored
Symbolic link
1
node_modules/.bin/barcodes
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes
|
||||
1
node_modules/.bin/canvas.js
generated
vendored
Symbolic link
1
node_modules/.bin/canvas.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers/canvas.js
|
||||
1
node_modules/.bin/checksums.js
generated
vendored
Symbolic link
1
node_modules/.bin/checksums.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/MSI/checksums.js
|
||||
1
node_modules/.bin/codabar
generated
vendored
Symbolic link
1
node_modules/.bin/codabar
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/codabar
|
||||
1
node_modules/.bin/constants.js
generated
vendored
Symbolic link
1
node_modules/.bin/constants.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/ITF/constants.js
|
||||
1
node_modules/.bin/defaults.js
generated
vendored
Symbolic link
1
node_modules/.bin/defaults.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/options/defaults.js
|
||||
1
node_modules/.bin/encoder.js
generated
vendored
Symbolic link
1
node_modules/.bin/encoder.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/EAN_UPC/encoder.js
|
||||
1
node_modules/.bin/exceptions
generated
vendored
Symbolic link
1
node_modules/.bin/exceptions
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/exceptions
|
||||
1
node_modules/.bin/exceptions.js
generated
vendored
Symbolic link
1
node_modules/.bin/exceptions.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/exceptions/exceptions.js
|
||||
1
node_modules/.bin/fixOptions.js
generated
vendored
Symbolic link
1
node_modules/.bin/fixOptions.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/fixOptions.js
|
||||
1
node_modules/.bin/getOptionsFromElement.js
generated
vendored
Symbolic link
1
node_modules/.bin/getOptionsFromElement.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/getOptionsFromElement.js
|
||||
1
node_modules/.bin/getRenderProperties.js
generated
vendored
Symbolic link
1
node_modules/.bin/getRenderProperties.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/getRenderProperties.js
|
||||
1
node_modules/.bin/help
generated
vendored
Symbolic link
1
node_modules/.bin/help
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help
|
||||
1
node_modules/.bin/index.js
generated
vendored
Symbolic link
1
node_modules/.bin/index.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers/index.js
|
||||
1
node_modules/.bin/index.tmp.js
generated
vendored
Symbolic link
1
node_modules/.bin/index.tmp.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/index.tmp.js
|
||||
1
node_modules/.bin/linearizeEncodings.js
generated
vendored
Symbolic link
1
node_modules/.bin/linearizeEncodings.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/linearizeEncodings.js
|
||||
1
node_modules/.bin/merge.js
generated
vendored
Symbolic link
1
node_modules/.bin/merge.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/merge.js
|
||||
1
node_modules/.bin/object.js
generated
vendored
Symbolic link
1
node_modules/.bin/object.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers/object.js
|
||||
1
node_modules/.bin/options
generated
vendored
Symbolic link
1
node_modules/.bin/options
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/options
|
||||
1
node_modules/.bin/optionsFromStrings.js
generated
vendored
Symbolic link
1
node_modules/.bin/optionsFromStrings.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/help/optionsFromStrings.js
|
||||
1
node_modules/.bin/pharmacode
generated
vendored
Symbolic link
1
node_modules/.bin/pharmacode
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/barcodes/pharmacode
|
||||
1
node_modules/.bin/renderers
generated
vendored
Symbolic link
1
node_modules/.bin/renderers
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers
|
||||
1
node_modules/.bin/shared.js
generated
vendored
Symbolic link
1
node_modules/.bin/shared.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers/shared.js
|
||||
1
node_modules/.bin/svg.js
generated
vendored
Symbolic link
1
node_modules/.bin/svg.js
generated
vendored
Symbolic link
@@ -0,0 +1 @@
|
||||
../jsbarcode/bin/renderers/svg.js
|
||||
47
node_modules/fs/package.json
generated
vendored
47
node_modules/fs/package.json
generated
vendored
@@ -1,20 +1,45 @@
|
||||
{
|
||||
"_from": "fs@0.0.1-security",
|
||||
"_id": "fs@0.0.1-security",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=",
|
||||
"_location": "/fs",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "fs@0.0.1-security",
|
||||
"name": "fs",
|
||||
"version": "0.0.1-security",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
"escapedName": "fs",
|
||||
"rawSpec": "0.0.1-security",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "0.0.1-security"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
|
||||
"_shasum": "8a7bd37186b6dddf3813f23858b57ecaaf5e41d4",
|
||||
"_spec": "fs@0.0.1-security",
|
||||
"_where": "/home/frappe/frappe-bench/apps/label_printing",
|
||||
"author": "",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/security-holder/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "This package name is not currently in use, but was formerly occupied by another package. To avoid malicious use, npm is hanging on to the package name, but loosely, and we'll probably give it to you if you want it.",
|
||||
"homepage": "https://github.com/npm/security-holder#readme",
|
||||
"keywords": [],
|
||||
"license": "ISC",
|
||||
"main": "index.js",
|
||||
"name": "fs",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/security-holder.git"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/security-holder/issues"
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"homepage": "https://github.com/npm/security-holder#readme"
|
||||
"version": "0.0.1-security"
|
||||
}
|
||||
|
||||
54
node_modules/inherits/package.json
generated
vendored
54
node_modules/inherits/package.json
generated
vendored
@@ -1,7 +1,42 @@
|
||||
{
|
||||
"_from": "inherits@2.0.3",
|
||||
"_id": "inherits@2.0.3",
|
||||
"_inBundle": false,
|
||||
"_integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=",
|
||||
"_location": "/inherits",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"type": "version",
|
||||
"registry": true,
|
||||
"raw": "inherits@2.0.3",
|
||||
"name": "inherits",
|
||||
"escapedName": "inherits",
|
||||
"rawSpec": "2.0.3",
|
||||
"saveSpec": null,
|
||||
"fetchSpec": "2.0.3"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/util"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
|
||||
"_shasum": "633c2c83e3da42a502f52466022480f4208261de",
|
||||
"_spec": "inherits@2.0.3",
|
||||
"_where": "/home/frappe/frappe-bench/apps/label_printing/node_modules/util",
|
||||
"browser": "./inherits_browser.js",
|
||||
"bugs": {
|
||||
"url": "https://github.com/isaacs/inherits/issues"
|
||||
},
|
||||
"bundleDependencies": false,
|
||||
"deprecated": false,
|
||||
"description": "Browser-friendly inheritance fully compatible with standard node.js inherits()",
|
||||
"version": "2.0.3",
|
||||
"devDependencies": {
|
||||
"tap": "^7.1.0"
|
||||
},
|
||||
"files": [
|
||||
"inherits.js",
|
||||
"inherits_browser.js"
|
||||
],
|
||||
"homepage": "https://github.com/isaacs/inherits#readme",
|
||||
"keywords": [
|
||||
"inheritance",
|
||||
"class",
|
||||
@@ -12,18 +47,15 @@
|
||||
"browser",
|
||||
"browserify"
|
||||
],
|
||||
"main": "./inherits.js",
|
||||
"browser": "./inherits_browser.js",
|
||||
"repository": "git://github.com/isaacs/inherits",
|
||||
"license": "ISC",
|
||||
"main": "./inherits.js",
|
||||
"name": "inherits",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/isaacs/inherits.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node test"
|
||||
},
|
||||
"devDependencies": {
|
||||
"tap": "^7.1.0"
|
||||
},
|
||||
"files": [
|
||||
"inherits.js",
|
||||
"inherits_browser.js"
|
||||
]
|
||||
"version": "2.0.3"
|
||||
}
|
||||
|
||||
1
node_modules/jsbarcode/.dockerignore
generated
vendored
Normal file
1
node_modules/jsbarcode/.dockerignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
**/node_modules
|
||||
4
node_modules/jsbarcode/.eslintignore
generated
vendored
Normal file
4
node_modules/jsbarcode/.eslintignore
generated
vendored
Normal file
@@ -0,0 +1,4 @@
|
||||
test
|
||||
bin
|
||||
dist
|
||||
example
|
||||
24
node_modules/jsbarcode/.eslintrc
generated
vendored
Normal file
24
node_modules/jsbarcode/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,24 @@
|
||||
{
|
||||
"env": {
|
||||
"browser": true,
|
||||
"node": true
|
||||
},
|
||||
"parserOptions": {
|
||||
"ecmaVersion": 7,
|
||||
"sourceType": "module",
|
||||
"ecmaFeatures": {
|
||||
"experimentalObjectRestSpread": true
|
||||
}
|
||||
},
|
||||
"extends": "eslint:recommended",
|
||||
"predef": "jQuery",
|
||||
"rules": {
|
||||
"curly": "error",
|
||||
"semi": [1, "always"],
|
||||
"no-console": 2,
|
||||
"no-control-regex": 0,
|
||||
"indent": [1, "tab", {"SwitchCase": 1}],
|
||||
"space-infix-ops": ["error"],
|
||||
"comma-spacing": ["error"]
|
||||
}
|
||||
}
|
||||
16
node_modules/jsbarcode/.travis.yml
generated
vendored
Normal file
16
node_modules/jsbarcode/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,16 @@
|
||||
language: node_js
|
||||
sudo: required
|
||||
before_install:
|
||||
- sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
|
||||
- sudo apt-get update
|
||||
- npm install -g gulp
|
||||
install:
|
||||
- sudo apt-get install libcairo2-dev libjpeg8-dev libpango1.0-dev libgif-dev build-essential g++-4.8
|
||||
- sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 50
|
||||
- npm install
|
||||
after_success: npm run coveralls
|
||||
node_js:
|
||||
- "node"
|
||||
- "14"
|
||||
- "12"
|
||||
- "10"
|
||||
84
node_modules/jsbarcode/CONTRIBUTING.md
generated
vendored
Normal file
84
node_modules/jsbarcode/CONTRIBUTING.md
generated
vendored
Normal file
@@ -0,0 +1,84 @@
|
||||
Getting Started
|
||||
----
|
||||
We would :heart: to have pull requests for you. So here is how you start development with JsBarcode.
|
||||
|
||||
First fork and clone the repo:
|
||||
````bash
|
||||
git clone git@github.com:your-username/JsBarcode.git
|
||||
````
|
||||
|
||||
Then run ``npm install`` to set everything up. Make sure you have all dependencies of [node-canvas](https://github.com/Automattic/node-canvas) installed before doing this, or check **Using Docker** section.
|
||||
|
||||
You are now ready to start doing your changes.
|
||||
|
||||
JsBarcode is using [gulp](http://gulpjs.com/) in the building step. Here comes some commands that will come handy when developing.
|
||||
|
||||
````bash
|
||||
gulp compile # Compile the code (for nodejs)
|
||||
gulp compile-web # Compiles down to JsBarcode.all.js
|
||||
gulp compress # Compiles and compresses all individual barcode files
|
||||
|
||||
gulp watch # Listens to file changes and re-compiles automatically
|
||||
gulp watch-web # Listens to file changes and re-compiles to JsBarcode.all.js automatically
|
||||
|
||||
gulp lint # Checking the code according to the code style specified in .eslintrc
|
||||
````
|
||||
|
||||
Testing
|
||||
----
|
||||
JsBarcode has tests on all barcode symbologies (and more). If you want to test your changes just run ``npm test`` and the code will be compiled and tested.
|
||||
|
||||
There are also visual tests located under ``test/browser/``.
|
||||
|
||||
Using Docker
|
||||
----
|
||||
If you have installed [Docker](https://www.docker.com), you can avoid local installation of dependencies for [node-canvas](https://github.com/Automattic/node-canvas). For doing that, run ``npm install --ignore-scripts`` instead of ``npm install``. Then you can run tests by ``docker-compose up``
|
||||
|
||||
Symbologies and The Core
|
||||
----
|
||||
JsBarcode is divided up in two distinct parts. The barcode symbologies (EAN-13, CODE128, ITF, ...) and the core.
|
||||
|
||||
### Symbologies
|
||||
Implementing a new symbology is the easiest way to contribute. Just follow the standard for that symbology and create a class that generate the correct binary data.
|
||||
|
||||
The structure of such a class is as follows:
|
||||
|
||||
````javascript
|
||||
import Barcode from "../Barcode.js";
|
||||
|
||||
class GenericBarcode extends Barcode{
|
||||
constructor(data, options){
|
||||
super(data, options); // Sets this.data and this.text
|
||||
}
|
||||
|
||||
// Return the corresponding binary numbers for the data provided
|
||||
encode(){
|
||||
return {
|
||||
data: "10101010101010101010101010101010101010101",
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
// Resturn true/false if the string provided is valid for this encoder
|
||||
valid(){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
````
|
||||
|
||||
It might be a good idea to check one of the already implemented barcodes (such as [ITF14](https://github.com/lindell/JsBarcode/blob/master/src/barcodes/ITF14/index.js)) for inspiration.
|
||||
|
||||
### The Core / Renderers
|
||||
The core part handles the API requests and calls the renderers. If you want to do any structural changes please [create an issue](https://github.com/lindell/JsBarcode/issues/new) or ask about it in the [gitter chat](https://gitter.im/lindell/JsBarcode) first.
|
||||
|
||||
Bug fixes is of course welcome at any time :+1:
|
||||
|
||||
Pull Requests
|
||||
----
|
||||
So you are ready to make a PR? Great! :smile:
|
||||
|
||||
But first make sure you have checked some things.
|
||||
|
||||
* Your code should follow the code style guide provided by [.eslintrc](https://github.com/lindell/JsBarcode/blob/master/.eslintrc) by running ``gulp lint``
|
||||
* If you implemented a new symbology, make sure you have tests for it
|
||||
* Don't commit build changes. No `dist/` or `bin/` changes in the PR.
|
||||
13
node_modules/jsbarcode/Dockerfile
generated
vendored
Normal file
13
node_modules/jsbarcode/Dockerfile
generated
vendored
Normal file
@@ -0,0 +1,13 @@
|
||||
FROM node:8
|
||||
|
||||
RUN apt-get update && apt-get install -qq libcairo2-dev libjpeg-dev libpango1.0-dev libgif-dev build-essential g++
|
||||
|
||||
RUN mkdir -p /jsbarcode
|
||||
WORKDIR /jsbarcode
|
||||
COPY ./ ./
|
||||
|
||||
RUN npm install
|
||||
|
||||
CMD npm test
|
||||
|
||||
EXPOSE 3000
|
||||
7
node_modules/jsbarcode/MIT-LICENSE.txt
generated
vendored
Normal file
7
node_modules/jsbarcode/MIT-LICENSE.txt
generated
vendored
Normal file
@@ -0,0 +1,7 @@
|
||||
Copyright (c) 2016 Johan Lindell (johan@lindell.me)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
255
node_modules/jsbarcode/README.md
generated
vendored
Normal file
255
node_modules/jsbarcode/README.md
generated
vendored
Normal file
@@ -0,0 +1,255 @@
|
||||
<p align="center">
|
||||
<a href="http://lindell.me/JsBarcode"><img src="http://lindell.me/JsBarcode/other/logo.svg" alt="JsBarcode"/></a>
|
||||
<br><br>
|
||||
<a href="http://travis-ci.org/lindell/JsBarcode"><img src="https://secure.travis-ci.org/lindell/JsBarcode.svg" alt="Build Status"/></a>
|
||||
<a href="https://scrutinizer-ci.com/g/lindell/JsBarcode/?branch=master"><img src="https://scrutinizer-ci.com/g/lindell/JsBarcode/badges/quality-score.png?b=master" alt="Scrutinizer Code Quality"/></a>
|
||||
<a href="https://www.jsdelivr.com/package/npm/jsbarcode"><img src="https://data.jsdelivr.com/v1/package/npm/jsbarcode/badge?style=rounded" alt="CDN"></a>
|
||||
<a href="https://github.com/lindell/JsBarcode/blob/master/MIT-LICENSE.txt"><img src="https://img.shields.io/badge/license-MIT-blue.svg" alt="License"/></a>
|
||||
</p>
|
||||
|
||||
Introduction
|
||||
----
|
||||
**JsBarcode** is a **barcode generator** written in JavaScript. It supports multiple barcode formats and works in browsers and with *Node.js*. It has *no dependencies* when it is used for the web but works with *jQuery* if you are into that.
|
||||
|
||||
|
||||
|
||||
Demo
|
||||
----
|
||||
#### [Barcode Generator](http://lindell.github.io/JsBarcode/generator/)
|
||||
#### [Simple CodePen Demo](http://codepen.io/lindell/pen/eZKBdO?editors=1010)
|
||||
#### [Settings CodePen Demo](http://codepen.io/lindell/pen/mPvLXx?editors=1010)
|
||||
|
||||
Supported barcodes:
|
||||
----
|
||||
* [CODE128](https://github.com/lindell/JsBarcode/wiki/CODE128)
|
||||
* CODE128 (automatic mode switching)
|
||||
* CODE128 A/B/C (force mode)
|
||||
* [EAN](https://github.com/lindell/JsBarcode/wiki/EAN)
|
||||
* EAN-13
|
||||
* EAN-8
|
||||
* EAN-5
|
||||
* EAN-2
|
||||
* UPC (A)
|
||||
* UPC (E)
|
||||
* [CODE39](https://github.com/lindell/JsBarcode/wiki/CODE39)
|
||||
* [ITF](https://github.com/lindell/JsBarcode/wiki/ITF-14)
|
||||
* ITF
|
||||
* ITF-14
|
||||
* [MSI](https://github.com/lindell/JsBarcode/wiki/MSI)
|
||||
* MSI10
|
||||
* MSI11
|
||||
* MSI1010
|
||||
* MSI1110
|
||||
* [Pharmacode](https://github.com/lindell/JsBarcode/wiki/pharmacode)
|
||||
* [Codabar](https://github.com/lindell/JsBarcode/wiki/codabar)
|
||||
|
||||
Examples for browsers:
|
||||
----
|
||||
|
||||
#### First create a canvas (or image)
|
||||
````html
|
||||
<svg id="barcode"></svg>
|
||||
<!-- or -->
|
||||
<canvas id="barcode"></canvas>
|
||||
<!-- or -->
|
||||
<img id="barcode"/>
|
||||
````
|
||||
|
||||
|
||||
|
||||
#### Simple example:
|
||||
````javascript
|
||||
JsBarcode("#barcode", "Hi!");
|
||||
// or with jQuery
|
||||
$("#barcode").JsBarcode("Hi!");
|
||||
````
|
||||
|
||||
##### Result:
|
||||

|
||||
|
||||
|
||||
#### Example with options:
|
||||
````javascript
|
||||
JsBarcode("#barcode", "1234", {
|
||||
format: "pharmacode",
|
||||
lineColor: "#0aa",
|
||||
width:4,
|
||||
height:40,
|
||||
displayValue: false
|
||||
});
|
||||
````
|
||||
##### Result:
|
||||

|
||||
|
||||
|
||||
#### More advanced use case:
|
||||
````javascript
|
||||
JsBarcode("#barcode")
|
||||
.options({font: "OCR-B"}) // Will affect all barcodes
|
||||
.EAN13("1234567890128", {fontSize: 18, textMargin: 0})
|
||||
.blank(20) // Create space between the barcodes
|
||||
.EAN5("12345", {height: 85, textPosition: "top", fontSize: 16, marginTop: 15})
|
||||
.render();
|
||||
````
|
||||
##### Result:
|
||||

|
||||
|
||||
|
||||
|
||||
#### Or define the value and options in the HTML element:
|
||||
Use any `jsbarcode-*` or `data-*` as attributes where `*` is any option.
|
||||
````html
|
||||
<svg class="barcode"
|
||||
jsbarcode-format="upc"
|
||||
jsbarcode-value="123456789012"
|
||||
jsbarcode-textmargin="0"
|
||||
jsbarcode-fontoptions="bold">
|
||||
</svg>
|
||||
````
|
||||
|
||||
And then initialize it with:
|
||||
````javascript
|
||||
JsBarcode(".barcode").init();
|
||||
````
|
||||
|
||||
##### Result:
|
||||

|
||||
|
||||
|
||||
|
||||
#### Retrieve the barcode values so you can render it any way you'd like
|
||||
Pass in an object which will be filled with data.
|
||||
```javascript
|
||||
const data = {};
|
||||
JsBarcode(data, 'text', {...options});
|
||||
```
|
||||
data will be filled with a ``` encodings ``` property which has all the needed values.
|
||||
See wiki for an example of what data looks like.
|
||||
|
||||
|
||||
Setup for browsers:
|
||||
----
|
||||
### Step 1:
|
||||
Download or get the CDN link to the script:
|
||||
|
||||
| Name | Supported barcodes | Size (gzip) | CDN / Download |
|
||||
|------|--------------------|:-----------:|---------------:|
|
||||
| *All* | *All the barcodes!* | *10.1 kB* | *[JsBarcode.all.min.js][1]* |
|
||||
| CODE128 | CODE128 (auto and force mode) | 6.2 kB | [JsBarcode.code128.min.js][2] |
|
||||
| CODE39 | CODE39 | 5.1 kB | [JsBarcode.code39.min.js][3] |
|
||||
| EAN / UPC | EAN-13, EAN-8, EAN-5, EAN-2, UPC (A) | 6.7 kB | [JsBarcode.ean-upc.min.js][4] |
|
||||
| ITF | ITF, ITF-14 | 5 kB | [JsBarcode.itf.min.js][5] |
|
||||
| MSI | MSI, MSI10, MSI11, MSI1010, MSI1110 | 5 kB | [JsBarcode.msi.min.js][6] |
|
||||
| Pharmacode | Pharmacode | 4.7 kB | [JsBarcode.pharmacode.min.js][7] |
|
||||
| Codabar | Codabar | 4.9 kB | [JsBarcode.codabar.min.js][8] |
|
||||
|
||||
|
||||
### Step 2:
|
||||
Include the script in your code:
|
||||
|
||||
|
||||
````html
|
||||
<script src="JsBarcode.all.min.js"></script>
|
||||
````
|
||||
|
||||
### Step 3:
|
||||
You are done! Go generate some barcodes :smile:
|
||||
|
||||
Bower and npm:
|
||||
----
|
||||
You can also use [Bower](http://bower.io) or [npm](https://www.npmjs.com) to install and manage the library.
|
||||
````bash
|
||||
bower install jsbarcode --save
|
||||
````
|
||||
````bash
|
||||
npm install jsbarcode --save
|
||||
````
|
||||
|
||||
Node.js:
|
||||
----
|
||||
|
||||
#### With canvas:
|
||||
```` javascript
|
||||
var JsBarcode = require('jsbarcode');
|
||||
|
||||
// Canvas v1
|
||||
var Canvas = require("canvas");
|
||||
// Canvas v2
|
||||
var { createCanvas } = require("canvas");
|
||||
|
||||
// Canvas v1
|
||||
var canvas = new Canvas();
|
||||
// Canvas v2
|
||||
var canvas = createCanvas();
|
||||
|
||||
JsBarcode(canvas, "Hello");
|
||||
|
||||
// Do what you want with the canvas
|
||||
// See https://github.com/Automattic/node-canvas for more information
|
||||
````
|
||||
|
||||
#### With svg:
|
||||
```` javascript
|
||||
const { DOMImplementation, XMLSerializer } = require('xmldom');
|
||||
const xmlSerializer = new XMLSerializer();
|
||||
const document = new DOMImplementation().createDocument('http://www.w3.org/1999/xhtml', 'html', null);
|
||||
const svgNode = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
||||
|
||||
JsBarcode(svgNode, 'test', {
|
||||
xmlDocument: document,
|
||||
});
|
||||
|
||||
const svgText = xmlSerializer.serializeToString(svgNode);
|
||||
````
|
||||
|
||||
|
||||
Options:
|
||||
----
|
||||
For information about how to use the options, see [the wiki page](https://github.com/lindell/JsBarcode/wiki/Options).
|
||||
|
||||
| Option | Default value | Type |
|
||||
|--------|---------------|------|
|
||||
| [`format`](https://github.com/lindell/JsBarcode/wiki/Options#format) | `"auto" (CODE128)` | `String` |
|
||||
| [`width`](https://github.com/lindell/JsBarcode/wiki/Options#width) | `2` | `Number` |
|
||||
| [`height`](https://github.com/lindell/JsBarcode/wiki/Options#height) | `100` | `Number` |
|
||||
| [`displayValue`](https://github.com/lindell/JsBarcode/wiki/Options#display-value) | `true` | `Boolean` |
|
||||
| [`text`](https://github.com/lindell/JsBarcode/wiki/Options#text) | `undefined` | `String` |
|
||||
| [`fontOptions`](https://github.com/lindell/JsBarcode/wiki/Options#font-options) | `""` | `String` |
|
||||
| [`font`](https://github.com/lindell/JsBarcode/wiki/Options#font) | `"monospace"` | `String` |
|
||||
| [`textAlign`](https://github.com/lindell/JsBarcode/wiki/Options#text-align) | `"center"` | `String` |
|
||||
| [`textPosition`](https://github.com/lindell/JsBarcode/wiki/Options#text-position) | `"bottom"` | `String` |
|
||||
| [`textMargin`](https://github.com/lindell/JsBarcode/wiki/Options#text-margin) | `2` | `Number` |
|
||||
| [`fontSize`](https://github.com/lindell/JsBarcode/wiki/Options#font-size) | `20` | `Number` |
|
||||
| [`background`](https://github.com/lindell/JsBarcode/wiki/Options#background) | `"#ffffff"` | `String (CSS color)` |
|
||||
| [`lineColor`](https://github.com/lindell/JsBarcode/wiki/Options#line-color) | `"#000000"` | `String (CSS color)` |
|
||||
| [`margin`](https://github.com/lindell/JsBarcode/wiki/Options#margins) | `10` | `Number` |
|
||||
| [`marginTop`](https://github.com/lindell/JsBarcode/wiki/Options#margins) | `undefined` | `Number` |
|
||||
| [`marginBottom`](https://github.com/lindell/JsBarcode/wiki/Options#margins) | `undefined` | `Number` |
|
||||
| [`marginLeft`](https://github.com/lindell/JsBarcode/wiki/Options#margins) | `undefined` | `Number` |
|
||||
| [`marginRight`](https://github.com/lindell/JsBarcode/wiki/Options#margins) | `undefined` | `Number` |
|
||||
| [`valid`](https://github.com/lindell/JsBarcode/wiki/Options#valid) | `function(valid){}` | `Function` |
|
||||
|
||||
Contributions and feedback:
|
||||
----
|
||||
We :heart: contributions and feedback.
|
||||
|
||||
If you want to contribute, please check out the [CONTRIBUTING.md](https://github.com/lindell/JsBarcode/blob/master/CONTRIBUTING.md) file.
|
||||
|
||||
If you have any question or suggestion [create an issue](https://github.com/lindell/JsBarcode/issues/new) or ask about it in the [gitter chat](https://gitter.im/lindell/JsBarcode).
|
||||
|
||||
Bug reports should always be done with a [new issue](https://github.com/lindell/JsBarcode/issues/new).
|
||||
|
||||
License:
|
||||
----
|
||||
JsBarcode is shared under the [MIT license](https://github.com/lindell/JsBarcode/blob/master/MIT-LICENSE.txt). This means you can modify and use it however you want, even for comercial use. But please give this the Github repo a :star: and write a small comment of how you are using JsBarcode in the [gitter chat](https://gitter.im/lindell/JsBarcode).
|
||||
|
||||
|
||||
|
||||
[1]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/JsBarcode.all.min.js "jsdelivr all barcodes"
|
||||
[2]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.code128.min.js "jsdelivr code128"
|
||||
[3]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.code39.min.js "jsdelivr code39"
|
||||
[4]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.ean-upc.min.js "jsdelivr ean/upc"
|
||||
[5]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.itf.min.js "jsdelivr itf"
|
||||
[6]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.msi.min.js "jsdelivr msi"
|
||||
[7]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.pharmacode.min.js "jsdelivr pharmacode"
|
||||
[8]: https://cdn.jsdelivr.net/npm/jsbarcode@3.11.0/dist/barcodes/JsBarcode.codabar.min.js "jsdelivr codabar"
|
||||
37
node_modules/jsbarcode/automation/barcode-building.json
generated
vendored
Normal file
37
node_modules/jsbarcode/automation/barcode-building.json
generated
vendored
Normal file
@@ -0,0 +1,37 @@
|
||||
[
|
||||
{
|
||||
"name": "code39",
|
||||
"names": "CODE39",
|
||||
"barcodeFile": "./CODE39"
|
||||
},
|
||||
{
|
||||
"name": "code128",
|
||||
"names": ["CODE128, CODE128A, CODE128B, CODE128C"],
|
||||
"barcodeFile": "./CODE128"
|
||||
},
|
||||
{
|
||||
"name": "ean-upc",
|
||||
"names": "EAN13, EAN8, EAN5, EAN2, UPC",
|
||||
"barcodeFile": "./EAN_UPC"
|
||||
},
|
||||
{
|
||||
"name": "itf",
|
||||
"names": "ITF, ITF14",
|
||||
"barcodeFile": "./ITF"
|
||||
},
|
||||
{
|
||||
"name": "msi",
|
||||
"names": "MSI, MSI10, MSI11, MSI1010, MSI1110",
|
||||
"barcodeFile": "./MSI"
|
||||
},
|
||||
{
|
||||
"name": "pharmacode",
|
||||
"names": "pharmacode",
|
||||
"barcodeFile": "./pharmacode"
|
||||
},
|
||||
{
|
||||
"name": "codabar",
|
||||
"names": "codabar",
|
||||
"barcodeFile": "./codabar"
|
||||
}
|
||||
]
|
||||
132
node_modules/jsbarcode/automation/building.js
generated
vendored
Normal file
132
node_modules/jsbarcode/automation/building.js
generated
vendored
Normal file
@@ -0,0 +1,132 @@
|
||||
var gulp = require('gulp');
|
||||
var header = require('gulp-header');
|
||||
var clean = require('gulp-clean');
|
||||
var gulpWebpack = require('webpack-stream');
|
||||
var webpack = require('webpack');
|
||||
var babel = require("gulp-babel");
|
||||
var runSequence = require('gulp4-run-sequence');
|
||||
var fs = require('fs');
|
||||
|
||||
var settings = require('./settings.json');
|
||||
var shared = require('./shared.js');
|
||||
|
||||
gulp.task("clean", gulp.series(function () {
|
||||
return gulp.src(["bin/", "dist/"], { read: false })
|
||||
.pipe(clean());
|
||||
}));
|
||||
|
||||
|
||||
gulp.task("babel", gulp.series(function () {
|
||||
return babelFunc();
|
||||
}));
|
||||
|
||||
|
||||
function babelFunc() {
|
||||
return gulp.src("src/**/*")
|
||||
.pipe(babel({
|
||||
presets: ['es2015', 'stage-3']
|
||||
}))
|
||||
.pipe(gulp.dest("bin/"));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack", gulp.series(["babel"], function () {
|
||||
return webpackFunc();
|
||||
}));
|
||||
|
||||
|
||||
function webpackFunc() {
|
||||
return gulp.src('bin/JsBarcode.js')
|
||||
.pipe(gulpWebpack(
|
||||
{
|
||||
mode: "none",
|
||||
output: {
|
||||
filename: 'JsBarcode.all.js'
|
||||
}
|
||||
}
|
||||
, webpack))
|
||||
.pipe(gulp.dest("dist/"));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack-min", gulp.series(["babel"], function () {
|
||||
return webpackMin('all');
|
||||
}));
|
||||
|
||||
|
||||
function webpackMin(name, dest) {
|
||||
dest = dest || './';
|
||||
return gulp.src('bin/JsBarcode.js')
|
||||
.pipe(gulpWebpack(
|
||||
{
|
||||
mode: "production",
|
||||
output: {
|
||||
filename: shared.minifiedFilename(name)
|
||||
},
|
||||
}
|
||||
, webpack))
|
||||
.pipe(header(settings.banner, require(settings.baseDir + 'package.json')))
|
||||
.pipe(gulp.dest("dist/" + dest));
|
||||
}
|
||||
|
||||
|
||||
gulp.task("webpack-all", gulp.series(function (cb) {
|
||||
var barcodes = require('./barcode-building.json');
|
||||
|
||||
// Move the real barcodes/index.js out of the way while compiling the individual barcodes
|
||||
fs.renameSync("src/barcodes/index.js", "src/barcodes/index.tmp.js");
|
||||
|
||||
// Take a barcode from the barcodes array, call the functions to compile that
|
||||
// format and have a callback when it has finished.
|
||||
function loopBarcode(i) {
|
||||
if (i < barcodes.length) {
|
||||
createBarcodeInclude(barcodes[i], function () {
|
||||
loopBarcode(i + 1);
|
||||
});
|
||||
}
|
||||
else {
|
||||
fs.renameSync("src/barcodes/index.tmp.js", "src/barcodes/index.js");
|
||||
cb(); // Done
|
||||
}
|
||||
}
|
||||
|
||||
loopBarcode(0);
|
||||
}));
|
||||
|
||||
|
||||
// Takes information about a barcode formatSize
|
||||
// Modifies the barcodes/index.js file to only import the specified format
|
||||
// and then does a recompilation and minifies everything with webpack
|
||||
function createBarcodeInclude(barcode, callback) {
|
||||
var toFile = "";
|
||||
toFile += "import {" + barcode.names + "} from '" + barcode.barcodeFile + "'";
|
||||
toFile += "\n";
|
||||
toFile += "export default {" + barcode.names + "}";
|
||||
|
||||
// Write a new barcodes/index file that only includes the specified barcode
|
||||
fs.writeFile("src/barcodes/index.js", toFile, function () {
|
||||
// Remove the compiled barcodes/index file (if it exist)
|
||||
if (fs.existsSync("bin/barcodes/index.js")) {
|
||||
fs.unlinkSync("bin/barcodes/index.js");
|
||||
}
|
||||
// Re-compile with babel and webpack everything
|
||||
babelFunc().on('end', function () {
|
||||
webpackMin(barcode.name, 'barcodes/').on('end', callback);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
gulp.task('compress', gulp.series(function (cb) {
|
||||
runSequence(
|
||||
"clean",
|
||||
"webpack-all",
|
||||
"webpack",
|
||||
"webpack-min",
|
||||
cb
|
||||
);
|
||||
}));
|
||||
|
||||
gulp.task('compile', gulp.series(['babel']));
|
||||
|
||||
gulp.task('compile-web', gulp.series(['webpack']));
|
||||
9
node_modules/jsbarcode/automation/linting.js
generated
vendored
Normal file
9
node_modules/jsbarcode/automation/linting.js
generated
vendored
Normal file
@@ -0,0 +1,9 @@
|
||||
var gulp = require('gulp');
|
||||
var eslint = require('gulp-eslint');
|
||||
|
||||
gulp.task("lint", function () {
|
||||
return gulp.src(['src/**/*.js'])
|
||||
.pipe(eslint())
|
||||
.pipe(eslint.format())
|
||||
.pipe(eslint.failAfterError());
|
||||
});
|
||||
30
node_modules/jsbarcode/automation/misc.js
generated
vendored
Normal file
30
node_modules/jsbarcode/automation/misc.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
/*eslint no-console: 0 */
|
||||
|
||||
var gulp = require('gulp');
|
||||
var request = require('request');
|
||||
var fs = require('fs');
|
||||
|
||||
gulp.task('jsdelivr', function(callback){
|
||||
console.log("Making request...");
|
||||
request({
|
||||
url: "https://api.jsdelivr.com/v1/jsdelivr/libraries?name=jsbarcode",
|
||||
json: true
|
||||
}, function (error, response, body) {
|
||||
if (!error && response.statusCode === 200) {
|
||||
var readme = fs.readFileSync('README.md', "utf-8");
|
||||
var version = body[0].lastversion;
|
||||
|
||||
readme = readme.replace(/https:\/\/cdn\.jsdelivr\.net\/jsbarcode\/[0-9]+\.[0-9]+\.[0-9]+\//g,
|
||||
"https://cdn.jsdelivr.net/jsbarcode/" + version + "/");
|
||||
|
||||
fs.writeFileSync('README.md', readme, 'utf8');
|
||||
|
||||
console.log("New version: " + version);
|
||||
callback();
|
||||
}
|
||||
else{
|
||||
console.error("Failed to make jsdelivr api request");
|
||||
callback();
|
||||
}
|
||||
});
|
||||
});
|
||||
163
node_modules/jsbarcode/automation/releasing.js
generated
vendored
Normal file
163
node_modules/jsbarcode/automation/releasing.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/*eslint
|
||||
no-console: 0
|
||||
*/
|
||||
|
||||
var gulp = require('gulp');
|
||||
var bump = require('gulp-bump');
|
||||
var git = require('gulp-git');
|
||||
var publishRelease = require('publish-release');
|
||||
var gzipSize = require('gzip-size');
|
||||
var runSequence = require('gulp4-run-sequence');
|
||||
var fs = require('fs');
|
||||
|
||||
var settings = require('./settings.json');
|
||||
var shared = require('./shared.js');
|
||||
|
||||
|
||||
gulp.task('git-release', gulp.series(['compress'], function (cb) {
|
||||
var pkg = require(settings.baseDir + 'package.json');
|
||||
var v = 'v' + pkg.version;
|
||||
var message = ':package: Release ' + v;
|
||||
|
||||
updateReadmeFileSizes();
|
||||
|
||||
gulp.src(['./package.json', './bower.json', './README.md', './bin/', './dist'])
|
||||
.pipe(git.add({ args: '--all --force' }))
|
||||
.pipe(git.commit(message));
|
||||
|
||||
git.push('origin', 'master', function () {
|
||||
git.tag(v, message, function () {
|
||||
git.push('origin', 'master', { args: '--tags' }, cb);
|
||||
});
|
||||
});
|
||||
}));
|
||||
|
||||
|
||||
// Bump (increase) the version number
|
||||
gulp.task('bump-patch', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'patch' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('bump-minor', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'minor' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('bump-major', function () {
|
||||
return gulp.src(['./package.json', './bower.json'])
|
||||
.pipe(bump({ type: 'major' }))
|
||||
.pipe(gulp.dest('./'));
|
||||
});
|
||||
|
||||
|
||||
gulp.task('npm', function (done) {
|
||||
require('child_process').spawn('npm', ['publish'], { stdio: 'inherit' })
|
||||
.on('close', done);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('github-release', function (done) {
|
||||
var pkg = require(settings.baseDir + './package.json');
|
||||
var v = 'v' + pkg.version;
|
||||
var name = "JsBarcode " + v;
|
||||
|
||||
publishRelease({
|
||||
token: process.env.GITHUB_TOKEN,
|
||||
owner: "lindell",
|
||||
repo: "JsBarcode",
|
||||
tag: v,
|
||||
name: name,
|
||||
assets: [__dirname + "/" + settings.baseDir + "/dist/JsBarcode.all.min.js", __dirname + "/" + settings.baseDir + "/dist/JsBarcode.all.js"]
|
||||
}, done);
|
||||
});
|
||||
|
||||
|
||||
|
||||
gulp.task('release', gulp.series(function (callback) {
|
||||
runSequence(
|
||||
'git-release',
|
||||
'github-release',
|
||||
'npm',
|
||||
callback
|
||||
);
|
||||
}));
|
||||
|
||||
|
||||
gulp.task('patch', function () {
|
||||
runSequence(
|
||||
'bump-patch',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('minor', function () {
|
||||
runSequence(
|
||||
'bump-minor',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
gulp.task('major', function () {
|
||||
runSequence(
|
||||
'bump-major',
|
||||
'release',
|
||||
releaseDone
|
||||
);
|
||||
});
|
||||
|
||||
function releaseDone(error) {
|
||||
if (error) {
|
||||
console.log(error.message);
|
||||
}
|
||||
else {
|
||||
console.log('Successful!');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function updateReadmeFileSizes() {
|
||||
var files = require('./barcode-building.json');
|
||||
var readme = fs.readFileSync('README.md', "utf-8");
|
||||
|
||||
// Update .all files
|
||||
var allData = fs.readFileSync('dist/JsBarcode.all.min.js');
|
||||
var allFilesize = gzipSize.sync(allData);
|
||||
|
||||
var allRegexp = new RegExp('\\|[^\\|]*\\|([ \\t\\*]*\\[JsBarcode\\.all\\.min\\.js\\])');
|
||||
readme = readme.replace(allRegexp, "| *" + formatSize(allFilesize) + "* |$1");
|
||||
|
||||
// Update all barcodes files
|
||||
for (var i in files) {
|
||||
var filename = shared.minifiedFilename(files[i].name);
|
||||
|
||||
var fileData = fs.readFileSync('dist/barcodes/' + filename);
|
||||
var fileFilesize = gzipSize.sync(fileData);
|
||||
|
||||
var fileRegexp = new RegExp('\\|[^\\|]*\\|([ \\t]*\\[' + RegExp.escape(filename) + '\\])');
|
||||
|
||||
readme = readme.replace(fileRegexp, "| " + formatSize(fileFilesize) + " |$1");
|
||||
}
|
||||
|
||||
fs.writeFileSync('README.md', readme, 'utf8');
|
||||
}
|
||||
|
||||
|
||||
// Util functions
|
||||
RegExp.escape = function (s) {
|
||||
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&');
|
||||
};
|
||||
|
||||
function formatSize(bytes) {
|
||||
var kilobytes = Math.round(bytes / 1024 * 10) / 10;
|
||||
|
||||
return kilobytes + " kB";
|
||||
}
|
||||
6
node_modules/jsbarcode/automation/settings.json
generated
vendored
Normal file
6
node_modules/jsbarcode/automation/settings.json
generated
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
{
|
||||
"baseDir": "../",
|
||||
"distDir": "./dist/",
|
||||
"binDir": "./bin/",
|
||||
"banner": "/*! JsBarcode v<%= version %> | (c) <%= author %> | <%= license %> license */\n"
|
||||
}
|
||||
5
node_modules/jsbarcode/automation/shared.js
generated
vendored
Normal file
5
node_modules/jsbarcode/automation/shared.js
generated
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
module.exports = {};
|
||||
|
||||
module.exports.minifiedFilename = function(name){
|
||||
return "JsBarcode." + name + ".min.js";
|
||||
};
|
||||
252
node_modules/jsbarcode/bin/JsBarcode.js
generated
vendored
Executable file
252
node_modules/jsbarcode/bin/JsBarcode.js
generated
vendored
Executable file
@@ -0,0 +1,252 @@
|
||||
'use strict';
|
||||
|
||||
var _barcodes = require('./barcodes/');
|
||||
|
||||
var _barcodes2 = _interopRequireDefault(_barcodes);
|
||||
|
||||
var _merge = require('./help/merge.js');
|
||||
|
||||
var _merge2 = _interopRequireDefault(_merge);
|
||||
|
||||
var _linearizeEncodings = require('./help/linearizeEncodings.js');
|
||||
|
||||
var _linearizeEncodings2 = _interopRequireDefault(_linearizeEncodings);
|
||||
|
||||
var _fixOptions = require('./help/fixOptions.js');
|
||||
|
||||
var _fixOptions2 = _interopRequireDefault(_fixOptions);
|
||||
|
||||
var _getRenderProperties = require('./help/getRenderProperties.js');
|
||||
|
||||
var _getRenderProperties2 = _interopRequireDefault(_getRenderProperties);
|
||||
|
||||
var _optionsFromStrings = require('./help/optionsFromStrings.js');
|
||||
|
||||
var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
|
||||
|
||||
var _ErrorHandler = require('./exceptions/ErrorHandler.js');
|
||||
|
||||
var _ErrorHandler2 = _interopRequireDefault(_ErrorHandler);
|
||||
|
||||
var _exceptions = require('./exceptions/exceptions.js');
|
||||
|
||||
var _defaults = require('./options/defaults.js');
|
||||
|
||||
var _defaults2 = _interopRequireDefault(_defaults);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
// The protype of the object returned from the JsBarcode() call
|
||||
|
||||
|
||||
// Help functions
|
||||
var API = function API() {};
|
||||
|
||||
// The first call of the library API
|
||||
// Will return an object with all barcodes calls and the data that is used
|
||||
// by the renderers
|
||||
|
||||
|
||||
// Default values
|
||||
|
||||
|
||||
// Exceptions
|
||||
// Import all the barcodes
|
||||
var JsBarcode = function JsBarcode(element, text, options) {
|
||||
var api = new API();
|
||||
|
||||
if (typeof element === "undefined") {
|
||||
throw Error("No element to render on was provided.");
|
||||
}
|
||||
|
||||
// Variables that will be pased through the API calls
|
||||
api._renderProperties = (0, _getRenderProperties2.default)(element);
|
||||
api._encodings = [];
|
||||
api._options = _defaults2.default;
|
||||
api._errorHandler = new _ErrorHandler2.default(api);
|
||||
|
||||
// If text is set, use the simple syntax (render the barcode directly)
|
||||
if (typeof text !== "undefined") {
|
||||
options = options || {};
|
||||
|
||||
if (!options.format) {
|
||||
options.format = autoSelectBarcode();
|
||||
}
|
||||
|
||||
api.options(options)[options.format](text, options).render();
|
||||
}
|
||||
|
||||
return api;
|
||||
};
|
||||
|
||||
// To make tests work TODO: remove
|
||||
JsBarcode.getModule = function (name) {
|
||||
return _barcodes2.default[name];
|
||||
};
|
||||
|
||||
// Register all barcodes
|
||||
for (var name in _barcodes2.default) {
|
||||
if (_barcodes2.default.hasOwnProperty(name)) {
|
||||
// Security check if the propery is a prototype property
|
||||
registerBarcode(_barcodes2.default, name);
|
||||
}
|
||||
}
|
||||
function registerBarcode(barcodes, name) {
|
||||
API.prototype[name] = API.prototype[name.toUpperCase()] = API.prototype[name.toLowerCase()] = function (text, options) {
|
||||
var api = this;
|
||||
return api._errorHandler.wrapBarcodeCall(function () {
|
||||
// Ensure text is options.text
|
||||
options.text = typeof options.text === 'undefined' ? undefined : '' + options.text;
|
||||
|
||||
var newOptions = (0, _merge2.default)(api._options, options);
|
||||
newOptions = (0, _optionsFromStrings2.default)(newOptions);
|
||||
var Encoder = barcodes[name];
|
||||
var encoded = encode(text, Encoder, newOptions);
|
||||
api._encodings.push(encoded);
|
||||
|
||||
return api;
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
// encode() handles the Encoder call and builds the binary string to be rendered
|
||||
function encode(text, Encoder, options) {
|
||||
// Ensure that text is a string
|
||||
text = "" + text;
|
||||
|
||||
var encoder = new Encoder(text, options);
|
||||
|
||||
// If the input is not valid for the encoder, throw error.
|
||||
// If the valid callback option is set, call it instead of throwing error
|
||||
if (!encoder.valid()) {
|
||||
throw new _exceptions.InvalidInputException(encoder.constructor.name, text);
|
||||
}
|
||||
|
||||
// Make a request for the binary data (and other infromation) that should be rendered
|
||||
var encoded = encoder.encode();
|
||||
|
||||
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
|
||||
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
|
||||
encoded = (0, _linearizeEncodings2.default)(encoded);
|
||||
|
||||
// Merge
|
||||
for (var i = 0; i < encoded.length; i++) {
|
||||
encoded[i].options = (0, _merge2.default)(options, encoded[i].options);
|
||||
}
|
||||
|
||||
return encoded;
|
||||
}
|
||||
|
||||
function autoSelectBarcode() {
|
||||
// If CODE128 exists. Use it
|
||||
if (_barcodes2.default["CODE128"]) {
|
||||
return "CODE128";
|
||||
}
|
||||
|
||||
// Else, take the first (probably only) barcode
|
||||
return Object.keys(_barcodes2.default)[0];
|
||||
}
|
||||
|
||||
// Sets global encoder options
|
||||
// Added to the api by the JsBarcode function
|
||||
API.prototype.options = function (options) {
|
||||
this._options = (0, _merge2.default)(this._options, options);
|
||||
return this;
|
||||
};
|
||||
|
||||
// Will create a blank space (usually in between barcodes)
|
||||
API.prototype.blank = function (size) {
|
||||
var zeroes = new Array(size + 1).join("0");
|
||||
this._encodings.push({ data: zeroes });
|
||||
return this;
|
||||
};
|
||||
|
||||
// Initialize JsBarcode on all HTML elements defined.
|
||||
API.prototype.init = function () {
|
||||
// Should do nothing if no elements where found
|
||||
if (!this._renderProperties) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Make sure renderProperies is an array
|
||||
if (!Array.isArray(this._renderProperties)) {
|
||||
this._renderProperties = [this._renderProperties];
|
||||
}
|
||||
|
||||
var renderProperty;
|
||||
for (var i in this._renderProperties) {
|
||||
renderProperty = this._renderProperties[i];
|
||||
var options = (0, _merge2.default)(this._options, renderProperty.options);
|
||||
|
||||
if (options.format == "auto") {
|
||||
options.format = autoSelectBarcode();
|
||||
}
|
||||
|
||||
this._errorHandler.wrapBarcodeCall(function () {
|
||||
var text = options.value;
|
||||
var Encoder = _barcodes2.default[options.format.toUpperCase()];
|
||||
var encoded = encode(text, Encoder, options);
|
||||
|
||||
render(renderProperty, encoded, options);
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
// The render API call. Calls the real render function.
|
||||
API.prototype.render = function () {
|
||||
if (!this._renderProperties) {
|
||||
throw new _exceptions.NoElementException();
|
||||
}
|
||||
|
||||
if (Array.isArray(this._renderProperties)) {
|
||||
for (var i = 0; i < this._renderProperties.length; i++) {
|
||||
render(this._renderProperties[i], this._encodings, this._options);
|
||||
}
|
||||
} else {
|
||||
render(this._renderProperties, this._encodings, this._options);
|
||||
}
|
||||
|
||||
return this;
|
||||
};
|
||||
|
||||
API.prototype._defaults = _defaults2.default;
|
||||
|
||||
// Prepares the encodings and calls the renderer
|
||||
function render(renderProperties, encodings, options) {
|
||||
encodings = (0, _linearizeEncodings2.default)(encodings);
|
||||
|
||||
for (var i = 0; i < encodings.length; i++) {
|
||||
encodings[i].options = (0, _merge2.default)(options, encodings[i].options);
|
||||
(0, _fixOptions2.default)(encodings[i].options);
|
||||
}
|
||||
|
||||
(0, _fixOptions2.default)(options);
|
||||
|
||||
var Renderer = renderProperties.renderer;
|
||||
var renderer = new Renderer(renderProperties.element, encodings, options);
|
||||
renderer.render();
|
||||
|
||||
if (renderProperties.afterRender) {
|
||||
renderProperties.afterRender();
|
||||
}
|
||||
}
|
||||
|
||||
// Export to browser
|
||||
if (typeof window !== "undefined") {
|
||||
window.JsBarcode = JsBarcode;
|
||||
}
|
||||
|
||||
// Export to jQuery
|
||||
/*global jQuery */
|
||||
if (typeof jQuery !== 'undefined') {
|
||||
jQuery.fn.JsBarcode = function (content, options) {
|
||||
var elementArray = [];
|
||||
jQuery(this).each(function () {
|
||||
elementArray.push(this);
|
||||
});
|
||||
return JsBarcode(elementArray, content, options);
|
||||
};
|
||||
}
|
||||
|
||||
// Export to commonJS
|
||||
module.exports = JsBarcode;
|
||||
17
node_modules/jsbarcode/bin/barcodes/Barcode.js
generated
vendored
Executable file
17
node_modules/jsbarcode/bin/barcodes/Barcode.js
generated
vendored
Executable file
@@ -0,0 +1,17 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
var Barcode = function Barcode(data, options) {
|
||||
_classCallCheck(this, Barcode);
|
||||
|
||||
this.data = data;
|
||||
this.text = options.text || data;
|
||||
this.options = options;
|
||||
};
|
||||
|
||||
exports.default = Barcode;
|
||||
167
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128.js
generated
vendored
Executable file
167
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128.js
generated
vendored
Executable file
@@ -0,0 +1,167 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _Barcode2 = require('../Barcode.js');
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
// This is the master class,
|
||||
// it does require the start code to be included in the string
|
||||
var CODE128 = function (_Barcode) {
|
||||
_inherits(CODE128, _Barcode);
|
||||
|
||||
function CODE128(data, options) {
|
||||
_classCallCheck(this, CODE128);
|
||||
|
||||
// Get array of ascii codes from data
|
||||
var _this = _possibleConstructorReturn(this, (CODE128.__proto__ || Object.getPrototypeOf(CODE128)).call(this, data.substring(1), options));
|
||||
|
||||
_this.bytes = data.split('').map(function (char) {
|
||||
return char.charCodeAt(0);
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(CODE128, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
// ASCII value ranges 0-127, 200-211
|
||||
return (/^[\x00-\x7F\xC8-\xD3]+$/.test(this.data)
|
||||
);
|
||||
}
|
||||
|
||||
// The public encoding function
|
||||
|
||||
}, {
|
||||
key: 'encode',
|
||||
value: function encode() {
|
||||
var bytes = this.bytes;
|
||||
// Remove the start code from the bytes and set its index
|
||||
var startIndex = bytes.shift() - 105;
|
||||
// Get start set by index
|
||||
var startSet = _constants.SET_BY_CODE[startIndex];
|
||||
|
||||
if (startSet === undefined) {
|
||||
throw new RangeError('The encoding does not start with a start character.');
|
||||
}
|
||||
|
||||
if (this.shouldEncodeAsEan128() === true) {
|
||||
bytes.unshift(_constants.FNC1);
|
||||
}
|
||||
|
||||
// Start encode with the right type
|
||||
var encodingResult = CODE128.next(bytes, 1, startSet);
|
||||
|
||||
return {
|
||||
text: this.text === this.data ? this.text.replace(/[^\x20-\x7E]/g, '') : this.text,
|
||||
data:
|
||||
// Add the start bits
|
||||
CODE128.getBar(startIndex) +
|
||||
// Add the encoded bits
|
||||
encodingResult.result +
|
||||
// Add the checksum
|
||||
CODE128.getBar((encodingResult.checksum + startIndex) % _constants.MODULO) +
|
||||
// Add the end bits
|
||||
CODE128.getBar(_constants.STOP)
|
||||
};
|
||||
}
|
||||
|
||||
// GS1-128/EAN-128
|
||||
|
||||
}, {
|
||||
key: 'shouldEncodeAsEan128',
|
||||
value: function shouldEncodeAsEan128() {
|
||||
var isEAN128 = this.options.ean128 || false;
|
||||
if (typeof isEAN128 === 'string') {
|
||||
isEAN128 = isEAN128.toLowerCase() === 'true';
|
||||
}
|
||||
return isEAN128;
|
||||
}
|
||||
|
||||
// Get a bar symbol by index
|
||||
|
||||
}], [{
|
||||
key: 'getBar',
|
||||
value: function getBar(index) {
|
||||
return _constants.BARS[index] ? _constants.BARS[index].toString() : '';
|
||||
}
|
||||
|
||||
// Correct an index by a set and shift it from the bytes array
|
||||
|
||||
}, {
|
||||
key: 'correctIndex',
|
||||
value: function correctIndex(bytes, set) {
|
||||
if (set === _constants.SET_A) {
|
||||
var charCode = bytes.shift();
|
||||
return charCode < 32 ? charCode + 64 : charCode - 32;
|
||||
} else if (set === _constants.SET_B) {
|
||||
return bytes.shift() - 32;
|
||||
} else {
|
||||
return (bytes.shift() - 48) * 10 + bytes.shift() - 48;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'next',
|
||||
value: function next(bytes, pos, set) {
|
||||
if (!bytes.length) {
|
||||
return { result: '', checksum: 0 };
|
||||
}
|
||||
|
||||
var nextCode = void 0,
|
||||
index = void 0;
|
||||
|
||||
// Special characters
|
||||
if (bytes[0] >= 200) {
|
||||
index = bytes.shift() - 105;
|
||||
var nextSet = _constants.SWAP[index];
|
||||
|
||||
// Swap to other set
|
||||
if (nextSet !== undefined) {
|
||||
nextCode = CODE128.next(bytes, pos + 1, nextSet);
|
||||
}
|
||||
// Continue on current set but encode a special character
|
||||
else {
|
||||
// Shift
|
||||
if ((set === _constants.SET_A || set === _constants.SET_B) && index === _constants.SHIFT) {
|
||||
// Convert the next character so that is encoded correctly
|
||||
bytes[0] = set === _constants.SET_A ? bytes[0] > 95 ? bytes[0] - 96 : bytes[0] : bytes[0] < 32 ? bytes[0] + 96 : bytes[0];
|
||||
}
|
||||
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||
}
|
||||
}
|
||||
// Continue encoding
|
||||
else {
|
||||
index = CODE128.correctIndex(bytes, set);
|
||||
nextCode = CODE128.next(bytes, pos + 1, set);
|
||||
}
|
||||
|
||||
// Get the correct binary encoding and calculate the weight
|
||||
var enc = CODE128.getBar(index);
|
||||
var weight = index * pos;
|
||||
|
||||
return {
|
||||
result: enc + nextCode.result,
|
||||
checksum: weight + nextCode.checksum
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return CODE128;
|
||||
}(_Barcode3.default);
|
||||
|
||||
exports.default = CODE128;
|
||||
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128A.js
generated
vendored
Executable file
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128A.js
generated
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _CODE2 = require('./CODE128.js');
|
||||
|
||||
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var CODE128A = function (_CODE) {
|
||||
_inherits(CODE128A, _CODE);
|
||||
|
||||
function CODE128A(string, options) {
|
||||
_classCallCheck(this, CODE128A);
|
||||
|
||||
return _possibleConstructorReturn(this, (CODE128A.__proto__ || Object.getPrototypeOf(CODE128A)).call(this, _constants.A_START_CHAR + string, options));
|
||||
}
|
||||
|
||||
_createClass(CODE128A, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return new RegExp('^' + _constants.A_CHARS + '+$').test(this.data);
|
||||
}
|
||||
}]);
|
||||
|
||||
return CODE128A;
|
||||
}(_CODE3.default);
|
||||
|
||||
exports.default = CODE128A;
|
||||
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128B.js
generated
vendored
Executable file
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128B.js
generated
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _CODE2 = require('./CODE128.js');
|
||||
|
||||
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var CODE128B = function (_CODE) {
|
||||
_inherits(CODE128B, _CODE);
|
||||
|
||||
function CODE128B(string, options) {
|
||||
_classCallCheck(this, CODE128B);
|
||||
|
||||
return _possibleConstructorReturn(this, (CODE128B.__proto__ || Object.getPrototypeOf(CODE128B)).call(this, _constants.B_START_CHAR + string, options));
|
||||
}
|
||||
|
||||
_createClass(CODE128B, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return new RegExp('^' + _constants.B_CHARS + '+$').test(this.data);
|
||||
}
|
||||
}]);
|
||||
|
||||
return CODE128B;
|
||||
}(_CODE3.default);
|
||||
|
||||
exports.default = CODE128B;
|
||||
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128C.js
generated
vendored
Executable file
42
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128C.js
generated
vendored
Executable file
@@ -0,0 +1,42 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _CODE2 = require('./CODE128.js');
|
||||
|
||||
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var CODE128C = function (_CODE) {
|
||||
_inherits(CODE128C, _CODE);
|
||||
|
||||
function CODE128C(string, options) {
|
||||
_classCallCheck(this, CODE128C);
|
||||
|
||||
return _possibleConstructorReturn(this, (CODE128C.__proto__ || Object.getPrototypeOf(CODE128C)).call(this, _constants.C_START_CHAR + string, options));
|
||||
}
|
||||
|
||||
_createClass(CODE128C, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return new RegExp('^' + _constants.C_CHARS + '+$').test(this.data);
|
||||
}
|
||||
}]);
|
||||
|
||||
return CODE128C;
|
||||
}(_CODE3.default);
|
||||
|
||||
exports.default = CODE128C;
|
||||
41
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128_AUTO.js
generated
vendored
Executable file
41
node_modules/jsbarcode/bin/barcodes/CODE128/CODE128_AUTO.js
generated
vendored
Executable file
@@ -0,0 +1,41 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _CODE2 = require('./CODE128');
|
||||
|
||||
var _CODE3 = _interopRequireDefault(_CODE2);
|
||||
|
||||
var _auto = require('./auto');
|
||||
|
||||
var _auto2 = _interopRequireDefault(_auto);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var CODE128AUTO = function (_CODE) {
|
||||
_inherits(CODE128AUTO, _CODE);
|
||||
|
||||
function CODE128AUTO(data, options) {
|
||||
_classCallCheck(this, CODE128AUTO);
|
||||
|
||||
// ASCII value ranges 0-127, 200-211
|
||||
if (/^[\x00-\x7F\xC8-\xD3]+$/.test(data)) {
|
||||
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, (0, _auto2.default)(data), options));
|
||||
} else {
|
||||
var _this = _possibleConstructorReturn(this, (CODE128AUTO.__proto__ || Object.getPrototypeOf(CODE128AUTO)).call(this, data, options));
|
||||
}
|
||||
return _possibleConstructorReturn(_this);
|
||||
}
|
||||
|
||||
return CODE128AUTO;
|
||||
}(_CODE3.default);
|
||||
|
||||
exports.default = CODE128AUTO;
|
||||
73
node_modules/jsbarcode/bin/barcodes/CODE128/auto.js
generated
vendored
Executable file
73
node_modules/jsbarcode/bin/barcodes/CODE128/auto.js
generated
vendored
Executable file
@@ -0,0 +1,73 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
// Match Set functions
|
||||
var matchSetALength = function matchSetALength(string) {
|
||||
return string.match(new RegExp('^' + _constants.A_CHARS + '*'))[0].length;
|
||||
};
|
||||
var matchSetBLength = function matchSetBLength(string) {
|
||||
return string.match(new RegExp('^' + _constants.B_CHARS + '*'))[0].length;
|
||||
};
|
||||
var matchSetC = function matchSetC(string) {
|
||||
return string.match(new RegExp('^' + _constants.C_CHARS + '*'))[0];
|
||||
};
|
||||
|
||||
// CODE128A or CODE128B
|
||||
function autoSelectFromAB(string, isA) {
|
||||
var ranges = isA ? _constants.A_CHARS : _constants.B_CHARS;
|
||||
var untilC = string.match(new RegExp('^(' + ranges + '+?)(([0-9]{2}){2,})([^0-9]|$)'));
|
||||
|
||||
if (untilC) {
|
||||
return untilC[1] + String.fromCharCode(204) + autoSelectFromC(string.substring(untilC[1].length));
|
||||
}
|
||||
|
||||
var chars = string.match(new RegExp('^' + ranges + '+'))[0];
|
||||
|
||||
if (chars.length === string.length) {
|
||||
return string;
|
||||
}
|
||||
|
||||
return chars + String.fromCharCode(isA ? 205 : 206) + autoSelectFromAB(string.substring(chars.length), !isA);
|
||||
}
|
||||
|
||||
// CODE128C
|
||||
function autoSelectFromC(string) {
|
||||
var cMatch = matchSetC(string);
|
||||
var length = cMatch.length;
|
||||
|
||||
if (length === string.length) {
|
||||
return string;
|
||||
}
|
||||
|
||||
string = string.substring(length);
|
||||
|
||||
// Select A/B depending on the longest match
|
||||
var isA = matchSetALength(string) >= matchSetBLength(string);
|
||||
return cMatch + String.fromCharCode(isA ? 206 : 205) + autoSelectFromAB(string, isA);
|
||||
}
|
||||
|
||||
// Detect Code Set (A, B or C) and format the string
|
||||
|
||||
exports.default = function (string) {
|
||||
var newString = void 0;
|
||||
var cLength = matchSetC(string).length;
|
||||
|
||||
// Select 128C if the string start with enough digits
|
||||
if (cLength >= 2) {
|
||||
newString = _constants.C_START_CHAR + autoSelectFromC(string);
|
||||
} else {
|
||||
// Select A/B depending on the longest match
|
||||
var isA = matchSetALength(string) > matchSetBLength(string);
|
||||
newString = (isA ? _constants.A_START_CHAR : _constants.B_START_CHAR) + autoSelectFromAB(string, isA);
|
||||
}
|
||||
|
||||
return newString.replace(/[\xCD\xCE]([^])[\xCD\xCE]/, // Any sequence between 205 and 206 characters
|
||||
function (match, char) {
|
||||
return String.fromCharCode(203) + char;
|
||||
});
|
||||
};
|
||||
54
node_modules/jsbarcode/bin/barcodes/CODE128/constants.js
generated
vendored
Normal file
54
node_modules/jsbarcode/bin/barcodes/CODE128/constants.js
generated
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _SET_BY_CODE;
|
||||
|
||||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
||||
|
||||
// constants for internal usage
|
||||
var SET_A = exports.SET_A = 0;
|
||||
var SET_B = exports.SET_B = 1;
|
||||
var SET_C = exports.SET_C = 2;
|
||||
|
||||
// Special characters
|
||||
var SHIFT = exports.SHIFT = 98;
|
||||
var START_A = exports.START_A = 103;
|
||||
var START_B = exports.START_B = 104;
|
||||
var START_C = exports.START_C = 105;
|
||||
var MODULO = exports.MODULO = 103;
|
||||
var STOP = exports.STOP = 106;
|
||||
var FNC1 = exports.FNC1 = 207;
|
||||
|
||||
// Get set by start code
|
||||
var SET_BY_CODE = exports.SET_BY_CODE = (_SET_BY_CODE = {}, _defineProperty(_SET_BY_CODE, START_A, SET_A), _defineProperty(_SET_BY_CODE, START_B, SET_B), _defineProperty(_SET_BY_CODE, START_C, SET_C), _SET_BY_CODE);
|
||||
|
||||
// Get next set by code
|
||||
var SWAP = exports.SWAP = {
|
||||
101: SET_A,
|
||||
100: SET_B,
|
||||
99: SET_C
|
||||
};
|
||||
|
||||
var A_START_CHAR = exports.A_START_CHAR = String.fromCharCode(208); // START_A + 105
|
||||
var B_START_CHAR = exports.B_START_CHAR = String.fromCharCode(209); // START_B + 105
|
||||
var C_START_CHAR = exports.C_START_CHAR = String.fromCharCode(210); // START_C + 105
|
||||
|
||||
// 128A (Code Set A)
|
||||
// ASCII characters 00 to 95 (0–9, A–Z and control codes), special characters, and FNC 1–4
|
||||
var A_CHARS = exports.A_CHARS = "[\x00-\x5F\xC8-\xCF]";
|
||||
|
||||
// 128B (Code Set B)
|
||||
// ASCII characters 32 to 127 (0–9, A–Z, a–z), special characters, and FNC 1–4
|
||||
var B_CHARS = exports.B_CHARS = "[\x20-\x7F\xC8-\xCF]";
|
||||
|
||||
// 128C (Code Set C)
|
||||
// 00–99 (encodes two digits with a single code point) and FNC1
|
||||
var C_CHARS = exports.C_CHARS = "(\xCF*[0-9]{2}\xCF*)";
|
||||
|
||||
// CODE128 includes 107 symbols:
|
||||
// 103 data symbols, 3 start symbols (A, B and C), and 1 stop symbol (the last one)
|
||||
// Each symbol consist of three black bars (1) and three white spaces (0).
|
||||
var BARS = exports.BARS = [11011001100, 11001101100, 11001100110, 10010011000, 10010001100, 10001001100, 10011001000, 10011000100, 10001100100, 11001001000, 11001000100, 11000100100, 10110011100, 10011011100, 10011001110, 10111001100, 10011101100, 10011100110, 11001110010, 11001011100, 11001001110, 11011100100, 11001110100, 11101101110, 11101001100, 11100101100, 11100100110, 11101100100, 11100110100, 11100110010, 11011011000, 11011000110, 11000110110, 10100011000, 10001011000, 10001000110, 10110001000, 10001101000, 10001100010, 11010001000, 11000101000, 11000100010, 10110111000, 10110001110, 10001101110, 10111011000, 10111000110, 10001110110, 11101110110, 11010001110, 11000101110, 11011101000, 11011100010, 11011101110, 11101011000, 11101000110, 11100010110, 11101101000, 11101100010, 11100011010, 11101111010, 11001000010, 11110001010, 10100110000, 10100001100, 10010110000, 10010000110, 10000101100, 10000100110, 10110010000, 10110000100, 10011010000, 10011000010, 10000110100, 10000110010, 11000010010, 11001010000, 11110111010, 11000010100, 10001111010, 10100111100, 10010111100, 10010011110, 10111100100, 10011110100, 10011110010, 11110100100, 11110010100, 11110010010, 11011011110, 11011110110, 11110110110, 10101111000, 10100011110, 10001011110, 10111101000, 10111100010, 11110101000, 11110100010, 10111011110, 10111101110, 11101011110, 11110101110, 11010000100, 11010010000, 11010011100, 1100011101011];
|
||||
29
node_modules/jsbarcode/bin/barcodes/CODE128/index.js
generated
vendored
Normal file
29
node_modules/jsbarcode/bin/barcodes/CODE128/index.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.CODE128C = exports.CODE128B = exports.CODE128A = exports.CODE128 = undefined;
|
||||
|
||||
var _CODE128_AUTO = require('./CODE128_AUTO.js');
|
||||
|
||||
var _CODE128_AUTO2 = _interopRequireDefault(_CODE128_AUTO);
|
||||
|
||||
var _CODE128A = require('./CODE128A.js');
|
||||
|
||||
var _CODE128A2 = _interopRequireDefault(_CODE128A);
|
||||
|
||||
var _CODE128B = require('./CODE128B.js');
|
||||
|
||||
var _CODE128B2 = _interopRequireDefault(_CODE128B);
|
||||
|
||||
var _CODE128C = require('./CODE128C.js');
|
||||
|
||||
var _CODE128C2 = _interopRequireDefault(_CODE128C);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.CODE128 = _CODE128_AUTO2.default;
|
||||
exports.CODE128A = _CODE128A2.default;
|
||||
exports.CODE128B = _CODE128B2.default;
|
||||
exports.CODE128C = _CODE128C2.default;
|
||||
105
node_modules/jsbarcode/bin/barcodes/CODE39/index.js
generated
vendored
Normal file
105
node_modules/jsbarcode/bin/barcodes/CODE39/index.js
generated
vendored
Normal file
@@ -0,0 +1,105 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.CODE39 = undefined;
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _Barcode2 = require("../Barcode.js");
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Code_39#Encoding
|
||||
|
||||
var CODE39 = function (_Barcode) {
|
||||
_inherits(CODE39, _Barcode);
|
||||
|
||||
function CODE39(data, options) {
|
||||
_classCallCheck(this, CODE39);
|
||||
|
||||
data = data.toUpperCase();
|
||||
|
||||
// Calculate mod43 checksum if enabled
|
||||
if (options.mod43) {
|
||||
data += getCharacter(mod43checksum(data));
|
||||
}
|
||||
|
||||
return _possibleConstructorReturn(this, (CODE39.__proto__ || Object.getPrototypeOf(CODE39)).call(this, data, options));
|
||||
}
|
||||
|
||||
_createClass(CODE39, [{
|
||||
key: "encode",
|
||||
value: function encode() {
|
||||
// First character is always a *
|
||||
var result = getEncoding("*");
|
||||
|
||||
// Take every character and add the binary representation to the result
|
||||
for (var i = 0; i < this.data.length; i++) {
|
||||
result += getEncoding(this.data[i]) + "0";
|
||||
}
|
||||
|
||||
// Last character is always a *
|
||||
result += getEncoding("*");
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "valid",
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9A-Z\-\.\ \$\/\+\%]+$/) !== -1;
|
||||
}
|
||||
}]);
|
||||
|
||||
return CODE39;
|
||||
}(_Barcode3.default);
|
||||
|
||||
// All characters. The position in the array is the (checksum) value
|
||||
|
||||
|
||||
var characters = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z", "-", ".", " ", "$", "/", "+", "%", "*"];
|
||||
|
||||
// The decimal representation of the characters, is converted to the
|
||||
// corresponding binary with the getEncoding function
|
||||
var encodings = [20957, 29783, 23639, 30485, 20951, 29813, 23669, 20855, 29789, 23645, 29975, 23831, 30533, 22295, 30149, 24005, 21623, 29981, 23837, 22301, 30023, 23879, 30545, 22343, 30161, 24017, 21959, 30065, 23921, 22385, 29015, 18263, 29141, 17879, 29045, 18293, 17783, 29021, 18269, 17477, 17489, 17681, 20753, 35770];
|
||||
|
||||
// Get the binary representation of a character by converting the encodings
|
||||
// from decimal to binary
|
||||
function getEncoding(character) {
|
||||
return getBinary(characterValue(character));
|
||||
}
|
||||
|
||||
function getBinary(characterValue) {
|
||||
return encodings[characterValue].toString(2);
|
||||
}
|
||||
|
||||
function getCharacter(characterValue) {
|
||||
return characters[characterValue];
|
||||
}
|
||||
|
||||
function characterValue(character) {
|
||||
return characters.indexOf(character);
|
||||
}
|
||||
|
||||
function mod43checksum(data) {
|
||||
var checksum = 0;
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
checksum += characterValue(data[i]);
|
||||
}
|
||||
|
||||
checksum = checksum % 43;
|
||||
return checksum;
|
||||
}
|
||||
|
||||
exports.CODE39 = CODE39;
|
||||
92
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN.js
generated
vendored
Executable file
92
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN.js
generated
vendored
Executable file
@@ -0,0 +1,92 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var _encoder = require('./encoder');
|
||||
|
||||
var _encoder2 = _interopRequireDefault(_encoder);
|
||||
|
||||
var _Barcode2 = require('../Barcode');
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
// Base class for EAN8 & EAN13
|
||||
var EAN = function (_Barcode) {
|
||||
_inherits(EAN, _Barcode);
|
||||
|
||||
function EAN(data, options) {
|
||||
_classCallCheck(this, EAN);
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
var _this = _possibleConstructorReturn(this, (EAN.__proto__ || Object.getPrototypeOf(EAN)).call(this, data, options));
|
||||
|
||||
_this.fontSize = !options.flat && options.fontSize > options.width * 10 ? options.width * 10 : options.fontSize;
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(EAN, [{
|
||||
key: 'encode',
|
||||
value: function encode() {
|
||||
return this.options.flat ? this.encodeFlat() : this.encodeGuarded();
|
||||
}
|
||||
}, {
|
||||
key: 'leftText',
|
||||
value: function leftText(from, to) {
|
||||
return this.text.substr(from, to);
|
||||
}
|
||||
}, {
|
||||
key: 'leftEncode',
|
||||
value: function leftEncode(data, structure) {
|
||||
return (0, _encoder2.default)(data, structure);
|
||||
}
|
||||
}, {
|
||||
key: 'rightText',
|
||||
value: function rightText(from, to) {
|
||||
return this.text.substr(from, to);
|
||||
}
|
||||
}, {
|
||||
key: 'rightEncode',
|
||||
value: function rightEncode(data, structure) {
|
||||
return (0, _encoder2.default)(data, structure);
|
||||
}
|
||||
}, {
|
||||
key: 'encodeGuarded',
|
||||
value: function encodeGuarded() {
|
||||
var textOptions = { fontSize: this.fontSize };
|
||||
var guardOptions = { height: this.guardHeight };
|
||||
|
||||
return [{ data: _constants.SIDE_BIN, options: guardOptions }, { data: this.leftEncode(), text: this.leftText(), options: textOptions }, { data: _constants.MIDDLE_BIN, options: guardOptions }, { data: this.rightEncode(), text: this.rightText(), options: textOptions }, { data: _constants.SIDE_BIN, options: guardOptions }];
|
||||
}
|
||||
}, {
|
||||
key: 'encodeFlat',
|
||||
value: function encodeFlat() {
|
||||
var data = [_constants.SIDE_BIN, this.leftEncode(), _constants.MIDDLE_BIN, this.rightEncode(), _constants.SIDE_BIN];
|
||||
|
||||
return {
|
||||
data: data.join(''),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return EAN;
|
||||
}(_Barcode3.default);
|
||||
|
||||
exports.default = EAN;
|
||||
119
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN13.js
generated
vendored
Executable file
119
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN13.js
generated
vendored
Executable file
@@ -0,0 +1,119 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var _EAN2 = require('./EAN');
|
||||
|
||||
var _EAN3 = _interopRequireDefault(_EAN2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Binary_encoding_of_data_digits_into_EAN-13_barcode
|
||||
|
||||
// Calculate the checksum digit
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||
var checksum = function checksum(number) {
|
||||
var res = number.substr(0, 12).split('').map(function (n) {
|
||||
return +n;
|
||||
}).reduce(function (sum, a, idx) {
|
||||
return idx % 2 ? sum + a * 3 : sum + a;
|
||||
}, 0);
|
||||
|
||||
return (10 - res % 10) % 10;
|
||||
};
|
||||
|
||||
var EAN13 = function (_EAN) {
|
||||
_inherits(EAN13, _EAN);
|
||||
|
||||
function EAN13(data, options) {
|
||||
_classCallCheck(this, EAN13);
|
||||
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{12}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
// Adds a last character to the end of the barcode
|
||||
var _this = _possibleConstructorReturn(this, (EAN13.__proto__ || Object.getPrototypeOf(EAN13)).call(this, data, options));
|
||||
|
||||
_this.lastChar = options.lastChar;
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(EAN13, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9]{13}$/) !== -1 && +this.data[12] === checksum(this.data);
|
||||
}
|
||||
}, {
|
||||
key: 'leftText',
|
||||
value: function leftText() {
|
||||
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftText', this).call(this, 1, 6);
|
||||
}
|
||||
}, {
|
||||
key: 'leftEncode',
|
||||
value: function leftEncode() {
|
||||
var data = this.data.substr(1, 6);
|
||||
var structure = _constants.EAN13_STRUCTURE[this.data[0]];
|
||||
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'leftEncode', this).call(this, data, structure);
|
||||
}
|
||||
}, {
|
||||
key: 'rightText',
|
||||
value: function rightText() {
|
||||
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightText', this).call(this, 7, 6);
|
||||
}
|
||||
}, {
|
||||
key: 'rightEncode',
|
||||
value: function rightEncode() {
|
||||
var data = this.data.substr(7, 6);
|
||||
return _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'rightEncode', this).call(this, data, 'RRRRRR');
|
||||
}
|
||||
|
||||
// The "standard" way of printing EAN13 barcodes with guard bars
|
||||
|
||||
}, {
|
||||
key: 'encodeGuarded',
|
||||
value: function encodeGuarded() {
|
||||
var data = _get(EAN13.prototype.__proto__ || Object.getPrototypeOf(EAN13.prototype), 'encodeGuarded', this).call(this);
|
||||
|
||||
// Extend data with left digit & last character
|
||||
if (this.options.displayValue) {
|
||||
data.unshift({
|
||||
data: '000000000000',
|
||||
text: this.text.substr(0, 1),
|
||||
options: { textAlign: 'left', fontSize: this.fontSize }
|
||||
});
|
||||
|
||||
if (this.options.lastChar) {
|
||||
data.push({
|
||||
data: '00'
|
||||
});
|
||||
data.push({
|
||||
data: '00000',
|
||||
text: this.options.lastChar,
|
||||
options: { fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return data;
|
||||
}
|
||||
}]);
|
||||
|
||||
return EAN13;
|
||||
}(_EAN3.default);
|
||||
|
||||
exports.default = EAN13;
|
||||
58
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN2.js
generated
vendored
Executable file
58
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN2.js
generated
vendored
Executable file
@@ -0,0 +1,58 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var _encoder = require('./encoder');
|
||||
|
||||
var _encoder2 = _interopRequireDefault(_encoder);
|
||||
|
||||
var _Barcode2 = require('../Barcode');
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/EAN_2#Encoding
|
||||
|
||||
var EAN2 = function (_Barcode) {
|
||||
_inherits(EAN2, _Barcode);
|
||||
|
||||
function EAN2(data, options) {
|
||||
_classCallCheck(this, EAN2);
|
||||
|
||||
return _possibleConstructorReturn(this, (EAN2.__proto__ || Object.getPrototypeOf(EAN2)).call(this, data, options));
|
||||
}
|
||||
|
||||
_createClass(EAN2, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9]{2}$/) !== -1;
|
||||
}
|
||||
}, {
|
||||
key: 'encode',
|
||||
value: function encode() {
|
||||
// Choose the structure based on the number mod 4
|
||||
var structure = _constants.EAN2_STRUCTURE[parseInt(this.data) % 4];
|
||||
return {
|
||||
// Start bits + Encode the two digits with 01 in between
|
||||
data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return EAN2;
|
||||
}(_Barcode3.default);
|
||||
|
||||
exports.default = EAN2;
|
||||
65
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN5.js
generated
vendored
Executable file
65
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN5.js
generated
vendored
Executable file
@@ -0,0 +1,65 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
var _encoder = require('./encoder');
|
||||
|
||||
var _encoder2 = _interopRequireDefault(_encoder);
|
||||
|
||||
var _Barcode2 = require('../Barcode');
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/EAN_5#Encoding
|
||||
|
||||
var checksum = function checksum(data) {
|
||||
var result = data.split('').map(function (n) {
|
||||
return +n;
|
||||
}).reduce(function (sum, a, idx) {
|
||||
return idx % 2 ? sum + a * 9 : sum + a * 3;
|
||||
}, 0);
|
||||
return result % 10;
|
||||
};
|
||||
|
||||
var EAN5 = function (_Barcode) {
|
||||
_inherits(EAN5, _Barcode);
|
||||
|
||||
function EAN5(data, options) {
|
||||
_classCallCheck(this, EAN5);
|
||||
|
||||
return _possibleConstructorReturn(this, (EAN5.__proto__ || Object.getPrototypeOf(EAN5)).call(this, data, options));
|
||||
}
|
||||
|
||||
_createClass(EAN5, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9]{5}$/) !== -1;
|
||||
}
|
||||
}, {
|
||||
key: 'encode',
|
||||
value: function encode() {
|
||||
var structure = _constants.EAN5_STRUCTURE[checksum(this.data)];
|
||||
return {
|
||||
data: '1011' + (0, _encoder2.default)(this.data, structure, '01'),
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}]);
|
||||
|
||||
return EAN5;
|
||||
}(_Barcode3.default);
|
||||
|
||||
exports.default = EAN5;
|
||||
81
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN8.js
generated
vendored
Executable file
81
node_modules/jsbarcode/bin/barcodes/EAN_UPC/EAN8.js
generated
vendored
Executable file
@@ -0,0 +1,81 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _get = function get(object, property, receiver) { if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { return get(parent, property, receiver); } } else if ("value" in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } };
|
||||
|
||||
var _EAN2 = require('./EAN');
|
||||
|
||||
var _EAN3 = _interopRequireDefault(_EAN2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// http://www.barcodeisland.com/ean8.phtml
|
||||
|
||||
// Calculate the checksum digit
|
||||
var checksum = function checksum(number) {
|
||||
var res = number.substr(0, 7).split('').map(function (n) {
|
||||
return +n;
|
||||
}).reduce(function (sum, a, idx) {
|
||||
return idx % 2 ? sum + a : sum + a * 3;
|
||||
}, 0);
|
||||
|
||||
return (10 - res % 10) % 10;
|
||||
};
|
||||
|
||||
var EAN8 = function (_EAN) {
|
||||
_inherits(EAN8, _EAN);
|
||||
|
||||
function EAN8(data, options) {
|
||||
_classCallCheck(this, EAN8);
|
||||
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{7}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
return _possibleConstructorReturn(this, (EAN8.__proto__ || Object.getPrototypeOf(EAN8)).call(this, data, options));
|
||||
}
|
||||
|
||||
_createClass(EAN8, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9]{8}$/) !== -1 && +this.data[7] === checksum(this.data);
|
||||
}
|
||||
}, {
|
||||
key: 'leftText',
|
||||
value: function leftText() {
|
||||
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftText', this).call(this, 0, 4);
|
||||
}
|
||||
}, {
|
||||
key: 'leftEncode',
|
||||
value: function leftEncode() {
|
||||
var data = this.data.substr(0, 4);
|
||||
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'leftEncode', this).call(this, data, 'LLLL');
|
||||
}
|
||||
}, {
|
||||
key: 'rightText',
|
||||
value: function rightText() {
|
||||
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightText', this).call(this, 4, 4);
|
||||
}
|
||||
}, {
|
||||
key: 'rightEncode',
|
||||
value: function rightEncode() {
|
||||
var data = this.data.substr(4, 4);
|
||||
return _get(EAN8.prototype.__proto__ || Object.getPrototypeOf(EAN8.prototype), 'rightEncode', this).call(this, data, 'RRRR');
|
||||
}
|
||||
}]);
|
||||
|
||||
return EAN8;
|
||||
}(_EAN3.default);
|
||||
|
||||
exports.default = EAN8;
|
||||
165
node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPC.js
generated
vendored
Executable file
165
node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPC.js
generated
vendored
Executable file
@@ -0,0 +1,165 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
exports.checksum = checksum;
|
||||
|
||||
var _encoder = require("./encoder");
|
||||
|
||||
var _encoder2 = _interopRequireDefault(_encoder);
|
||||
|
||||
var _Barcode2 = require("../Barcode.js");
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||
|
||||
var UPC = function (_Barcode) {
|
||||
_inherits(UPC, _Barcode);
|
||||
|
||||
function UPC(data, options) {
|
||||
_classCallCheck(this, UPC);
|
||||
|
||||
// Add checksum if it does not exist
|
||||
if (data.search(/^[0-9]{11}$/) !== -1) {
|
||||
data += checksum(data);
|
||||
}
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (UPC.__proto__ || Object.getPrototypeOf(UPC)).call(this, data, options));
|
||||
|
||||
_this.displayValue = options.displayValue;
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
if (options.fontSize > options.width * 10) {
|
||||
_this.fontSize = options.width * 10;
|
||||
} else {
|
||||
_this.fontSize = options.fontSize;
|
||||
}
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(UPC, [{
|
||||
key: "valid",
|
||||
value: function valid() {
|
||||
return this.data.search(/^[0-9]{12}$/) !== -1 && this.data[11] == checksum(this.data);
|
||||
}
|
||||
}, {
|
||||
key: "encode",
|
||||
value: function encode() {
|
||||
if (this.options.flat) {
|
||||
return this.flatEncoding();
|
||||
} else {
|
||||
return this.guardedEncoding();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: "flatEncoding",
|
||||
value: function flatEncoding() {
|
||||
var result = "";
|
||||
|
||||
result += "101";
|
||||
result += (0, _encoder2.default)(this.data.substr(0, 6), "LLLLLL");
|
||||
result += "01010";
|
||||
result += (0, _encoder2.default)(this.data.substr(6, 6), "RRRRRR");
|
||||
result += "101";
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: "guardedEncoding",
|
||||
value: function guardedEncoding() {
|
||||
var result = [];
|
||||
|
||||
// Add the first digit
|
||||
if (this.displayValue) {
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text.substr(0, 1),
|
||||
options: { textAlign: "left", fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
|
||||
// Add the guard bars
|
||||
result.push({
|
||||
data: "101" + (0, _encoder2.default)(this.data[0], "L"),
|
||||
options: { height: this.guardHeight }
|
||||
});
|
||||
|
||||
// Add the left side
|
||||
result.push({
|
||||
data: (0, _encoder2.default)(this.data.substr(1, 5), "LLLLL"),
|
||||
text: this.text.substr(1, 5),
|
||||
options: { fontSize: this.fontSize }
|
||||
});
|
||||
|
||||
// Add the middle bits
|
||||
result.push({
|
||||
data: "01010",
|
||||
options: { height: this.guardHeight }
|
||||
});
|
||||
|
||||
// Add the right side
|
||||
result.push({
|
||||
data: (0, _encoder2.default)(this.data.substr(6, 5), "RRRRR"),
|
||||
text: this.text.substr(6, 5),
|
||||
options: { fontSize: this.fontSize }
|
||||
});
|
||||
|
||||
// Add the end bits
|
||||
result.push({
|
||||
data: (0, _encoder2.default)(this.data[11], "R") + "101",
|
||||
options: { height: this.guardHeight }
|
||||
});
|
||||
|
||||
// Add the last digit
|
||||
if (this.displayValue) {
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text.substr(11, 1),
|
||||
options: { textAlign: "right", fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}]);
|
||||
|
||||
return UPC;
|
||||
}(_Barcode3.default);
|
||||
|
||||
// Calulate the checksum digit
|
||||
// https://en.wikipedia.org/wiki/International_Article_Number_(EAN)#Calculation_of_checksum_digit
|
||||
|
||||
|
||||
function checksum(number) {
|
||||
var result = 0;
|
||||
|
||||
var i;
|
||||
for (i = 1; i < 11; i += 2) {
|
||||
result += parseInt(number[i]);
|
||||
}
|
||||
for (i = 0; i < 11; i += 2) {
|
||||
result += parseInt(number[i]) * 3;
|
||||
}
|
||||
|
||||
return (10 - result % 10) % 10;
|
||||
}
|
||||
|
||||
exports.default = UPC;
|
||||
185
node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPCE.js
generated
vendored
Executable file
185
node_modules/jsbarcode/bin/barcodes/EAN_UPC/UPCE.js
generated
vendored
Executable file
@@ -0,0 +1,185 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _encoder = require('./encoder');
|
||||
|
||||
var _encoder2 = _interopRequireDefault(_encoder);
|
||||
|
||||
var _Barcode2 = require('../Barcode.js');
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
var _UPC = require('./UPC.js');
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } // Encoding documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
||||
//
|
||||
// UPC-E documentation:
|
||||
// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
|
||||
|
||||
var EXPANSIONS = ["XX00000XXX", "XX10000XXX", "XX20000XXX", "XXX00000XX", "XXXX00000X", "XXXXX00005", "XXXXX00006", "XXXXX00007", "XXXXX00008", "XXXXX00009"];
|
||||
|
||||
var PARITIES = [["EEEOOO", "OOOEEE"], ["EEOEOO", "OOEOEE"], ["EEOOEO", "OOEEOE"], ["EEOOOE", "OOEEEO"], ["EOEEOO", "OEOOEE"], ["EOOEEO", "OEEOOE"], ["EOOOEE", "OEEEOO"], ["EOEOEO", "OEOEOE"], ["EOEOOE", "OEOEEO"], ["EOOEOE", "OEEOEO"]];
|
||||
|
||||
var UPCE = function (_Barcode) {
|
||||
_inherits(UPCE, _Barcode);
|
||||
|
||||
function UPCE(data, options) {
|
||||
_classCallCheck(this, UPCE);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (UPCE.__proto__ || Object.getPrototypeOf(UPCE)).call(this, data, options));
|
||||
// Code may be 6 or 8 digits;
|
||||
// A 7 digit code is ambiguous as to whether the extra digit
|
||||
// is a UPC-A check or number system digit.
|
||||
|
||||
|
||||
_this.isValid = false;
|
||||
if (data.search(/^[0-9]{6}$/) !== -1) {
|
||||
_this.middleDigits = data;
|
||||
_this.upcA = expandToUPCA(data, "0");
|
||||
_this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
|
||||
_this.isValid = true;
|
||||
} else if (data.search(/^[01][0-9]{7}$/) !== -1) {
|
||||
_this.middleDigits = data.substring(1, data.length - 1);
|
||||
_this.upcA = expandToUPCA(_this.middleDigits, data[0]);
|
||||
|
||||
if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
|
||||
_this.isValid = true;
|
||||
} else {
|
||||
// checksum mismatch
|
||||
return _possibleConstructorReturn(_this);
|
||||
}
|
||||
} else {
|
||||
return _possibleConstructorReturn(_this);
|
||||
}
|
||||
|
||||
_this.displayValue = options.displayValue;
|
||||
|
||||
// Make sure the font is not bigger than the space between the guard bars
|
||||
if (options.fontSize > options.width * 10) {
|
||||
_this.fontSize = options.width * 10;
|
||||
} else {
|
||||
_this.fontSize = options.fontSize;
|
||||
}
|
||||
|
||||
// Make the guard bars go down half the way of the text
|
||||
_this.guardHeight = options.height + _this.fontSize / 2 + options.textMargin;
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(UPCE, [{
|
||||
key: 'valid',
|
||||
value: function valid() {
|
||||
return this.isValid;
|
||||
}
|
||||
}, {
|
||||
key: 'encode',
|
||||
value: function encode() {
|
||||
if (this.options.flat) {
|
||||
return this.flatEncoding();
|
||||
} else {
|
||||
return this.guardedEncoding();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'flatEncoding',
|
||||
value: function flatEncoding() {
|
||||
var result = "";
|
||||
|
||||
result += "101";
|
||||
result += this.encodeMiddleDigits();
|
||||
result += "010101";
|
||||
|
||||
return {
|
||||
data: result,
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
}, {
|
||||
key: 'guardedEncoding',
|
||||
value: function guardedEncoding() {
|
||||
var result = [];
|
||||
|
||||
// Add the UPC-A number system digit beneath the quiet zone
|
||||
if (this.displayValue) {
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text[0],
|
||||
options: { textAlign: "left", fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
|
||||
// Add the guard bars
|
||||
result.push({
|
||||
data: "101",
|
||||
options: { height: this.guardHeight }
|
||||
});
|
||||
|
||||
// Add the 6 UPC-E digits
|
||||
result.push({
|
||||
data: this.encodeMiddleDigits(),
|
||||
text: this.text.substring(1, 7),
|
||||
options: { fontSize: this.fontSize }
|
||||
});
|
||||
|
||||
// Add the end bits
|
||||
result.push({
|
||||
data: "010101",
|
||||
options: { height: this.guardHeight }
|
||||
});
|
||||
|
||||
// Add the UPC-A check digit beneath the quiet zone
|
||||
if (this.displayValue) {
|
||||
result.push({
|
||||
data: "00000000",
|
||||
text: this.text[7],
|
||||
options: { textAlign: "right", fontSize: this.fontSize }
|
||||
});
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}, {
|
||||
key: 'encodeMiddleDigits',
|
||||
value: function encodeMiddleDigits() {
|
||||
var numberSystem = this.upcA[0];
|
||||
var checkDigit = this.upcA[this.upcA.length - 1];
|
||||
var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
|
||||
return (0, _encoder2.default)(this.middleDigits, parity);
|
||||
}
|
||||
}]);
|
||||
|
||||
return UPCE;
|
||||
}(_Barcode3.default);
|
||||
|
||||
function expandToUPCA(middleDigits, numberSystem) {
|
||||
var lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
|
||||
var expansion = EXPANSIONS[lastUpcE];
|
||||
|
||||
var result = "";
|
||||
var digitIndex = 0;
|
||||
for (var i = 0; i < expansion.length; i++) {
|
||||
var c = expansion[i];
|
||||
if (c === 'X') {
|
||||
result += middleDigits[digitIndex++];
|
||||
} else {
|
||||
result += c;
|
||||
}
|
||||
}
|
||||
|
||||
result = '' + numberSystem + result;
|
||||
return '' + result + (0, _UPC.checksum)(result);
|
||||
}
|
||||
|
||||
exports.default = UPCE;
|
||||
30
node_modules/jsbarcode/bin/barcodes/EAN_UPC/constants.js
generated
vendored
Normal file
30
node_modules/jsbarcode/bin/barcodes/EAN_UPC/constants.js
generated
vendored
Normal file
@@ -0,0 +1,30 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
// Standard start end and middle bits
|
||||
var SIDE_BIN = exports.SIDE_BIN = '101';
|
||||
var MIDDLE_BIN = exports.MIDDLE_BIN = '01010';
|
||||
|
||||
var BINARIES = exports.BINARIES = {
|
||||
'L': [// The L (left) type of encoding
|
||||
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
|
||||
'G': [// The G type of encoding
|
||||
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111'],
|
||||
'R': [// The R (right) type of encoding
|
||||
'1110010', '1100110', '1101100', '1000010', '1011100', '1001110', '1010000', '1000100', '1001000', '1110100'],
|
||||
'O': [// The O (odd) encoding for UPC-E
|
||||
'0001101', '0011001', '0010011', '0111101', '0100011', '0110001', '0101111', '0111011', '0110111', '0001011'],
|
||||
'E': [// The E (even) encoding for UPC-E
|
||||
'0100111', '0110011', '0011011', '0100001', '0011101', '0111001', '0000101', '0010001', '0001001', '0010111']
|
||||
};
|
||||
|
||||
// Define the EAN-2 structure
|
||||
var EAN2_STRUCTURE = exports.EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
|
||||
|
||||
// Define the EAN-5 structure
|
||||
var EAN5_STRUCTURE = exports.EAN5_STRUCTURE = ['GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL', 'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'];
|
||||
|
||||
// Define the EAN-13 structure
|
||||
var EAN13_STRUCTURE = exports.EAN13_STRUCTURE = ['LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG', 'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'];
|
||||
27
node_modules/jsbarcode/bin/barcodes/EAN_UPC/encoder.js
generated
vendored
Executable file
27
node_modules/jsbarcode/bin/barcodes/EAN_UPC/encoder.js
generated
vendored
Executable file
@@ -0,0 +1,27 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
|
||||
var _constants = require('./constants');
|
||||
|
||||
// Encode data string
|
||||
var encode = function encode(data, structure, separator) {
|
||||
var encoded = data.split('').map(function (val, idx) {
|
||||
return _constants.BINARIES[structure[idx]];
|
||||
}).map(function (val, idx) {
|
||||
return val ? val[data[idx]] : '';
|
||||
});
|
||||
|
||||
if (separator) {
|
||||
var last = data.length - 1;
|
||||
encoded = encoded.map(function (val, idx) {
|
||||
return idx < last ? val + separator : val;
|
||||
});
|
||||
}
|
||||
|
||||
return encoded.join('');
|
||||
};
|
||||
|
||||
exports.default = encode;
|
||||
39
node_modules/jsbarcode/bin/barcodes/EAN_UPC/index.js
generated
vendored
Normal file
39
node_modules/jsbarcode/bin/barcodes/EAN_UPC/index.js
generated
vendored
Normal file
@@ -0,0 +1,39 @@
|
||||
'use strict';
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.UPCE = exports.UPC = exports.EAN2 = exports.EAN5 = exports.EAN8 = exports.EAN13 = undefined;
|
||||
|
||||
var _EAN = require('./EAN13.js');
|
||||
|
||||
var _EAN2 = _interopRequireDefault(_EAN);
|
||||
|
||||
var _EAN3 = require('./EAN8.js');
|
||||
|
||||
var _EAN4 = _interopRequireDefault(_EAN3);
|
||||
|
||||
var _EAN5 = require('./EAN5.js');
|
||||
|
||||
var _EAN6 = _interopRequireDefault(_EAN5);
|
||||
|
||||
var _EAN7 = require('./EAN2.js');
|
||||
|
||||
var _EAN8 = _interopRequireDefault(_EAN7);
|
||||
|
||||
var _UPC = require('./UPC.js');
|
||||
|
||||
var _UPC2 = _interopRequireDefault(_UPC);
|
||||
|
||||
var _UPCE = require('./UPCE.js');
|
||||
|
||||
var _UPCE2 = _interopRequireDefault(_UPCE);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
exports.EAN13 = _EAN2.default;
|
||||
exports.EAN8 = _EAN4.default;
|
||||
exports.EAN5 = _EAN6.default;
|
||||
exports.EAN2 = _EAN8.default;
|
||||
exports.UPC = _UPC2.default;
|
||||
exports.UPCE = _UPCE2.default;
|
||||
55
node_modules/jsbarcode/bin/barcodes/GenericBarcode/index.js
generated
vendored
Normal file
55
node_modules/jsbarcode/bin/barcodes/GenericBarcode/index.js
generated
vendored
Normal file
@@ -0,0 +1,55 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.GenericBarcode = undefined;
|
||||
|
||||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();
|
||||
|
||||
var _Barcode2 = require("../Barcode.js");
|
||||
|
||||
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
||||
|
||||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }
|
||||
|
||||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }
|
||||
|
||||
var GenericBarcode = function (_Barcode) {
|
||||
_inherits(GenericBarcode, _Barcode);
|
||||
|
||||
function GenericBarcode(data, options) {
|
||||
_classCallCheck(this, GenericBarcode);
|
||||
|
||||
return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
|
||||
}
|
||||
|
||||
// Return the corresponding binary numbers for the data provided
|
||||
|
||||
|
||||
_createClass(GenericBarcode, [{
|
||||
key: "encode",
|
||||
value: function encode() {
|
||||
return {
|
||||
data: "10101010101010101010101010101010101010101",
|
||||
text: this.text
|
||||
};
|
||||
}
|
||||
|
||||
// Resturn true/false if the string provided is valid for this encoder
|
||||
|
||||
}, {
|
||||
key: "valid",
|
||||
value: function valid() {
|
||||
return true;
|
||||
}
|
||||
}]);
|
||||
|
||||
return GenericBarcode;
|
||||
}(_Barcode3.default);
|
||||
|
||||
exports.GenericBarcode = GenericBarcode;
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user