yh-hiprint 2.3.5 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/HiprintDesigner.vue +494 -86
- package/hooks/useHiprint.js +48 -27
- package/libs/jquery.js +1 -0
- package/libs/jsbarcode/JsBarcode.js +225 -251
- package/libs/jsbarcode/barcodes/Barcode.js +9 -17
- package/libs/jsbarcode/barcodes/CODE128/CODE128.js +93 -133
- package/libs/jsbarcode/barcodes/CODE128/CODE128A.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128B.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128C.js +10 -38
- package/libs/jsbarcode/barcodes/CODE128/CODE128_AUTO.js +10 -36
- package/libs/jsbarcode/barcodes/CODE128/auto.js +32 -37
- package/libs/jsbarcode/barcodes/CODE128/constants.js +47 -30
- package/libs/jsbarcode/barcodes/CODE128/index.js +5 -28
- package/libs/jsbarcode/barcodes/CODE39/index.js +61 -61
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN.js +58 -78
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN13.js +66 -95
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN2.js +22 -50
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN5.js +29 -54
- package/libs/jsbarcode/barcodes/EAN_UPC/EAN8.js +42 -66
- package/libs/jsbarcode/barcodes/EAN_UPC/UPC.js +92 -125
- package/libs/jsbarcode/barcodes/EAN_UPC/UPCE.js +134 -142
- package/libs/jsbarcode/barcodes/EAN_UPC/constants.js +32 -21
- package/libs/jsbarcode/barcodes/EAN_UPC/encoder.js +11 -18
- package/libs/jsbarcode/barcodes/EAN_UPC/index.js +8 -39
- package/libs/jsbarcode/barcodes/GenericBarcode/index.js +16 -49
- package/libs/jsbarcode/barcodes/ITF/ITF.js +31 -63
- package/libs/jsbarcode/barcodes/ITF/ITF14.js +18 -40
- package/libs/jsbarcode/barcodes/ITF/constants.js +6 -8
- package/libs/jsbarcode/barcodes/ITF/index.js +3 -18
- package/libs/jsbarcode/barcodes/MSI/MSI.js +31 -57
- package/libs/jsbarcode/barcodes/MSI/MSI10.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1010.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/MSI11.js +7 -30
- package/libs/jsbarcode/barcodes/MSI/MSI1110.js +10 -33
- package/libs/jsbarcode/barcodes/MSI/checksums.js +11 -17
- package/libs/jsbarcode/barcodes/MSI/index.js +6 -33
- package/libs/jsbarcode/barcodes/codabar/index.js +49 -78
- package/libs/jsbarcode/barcodes/index.js +20 -33
- package/libs/jsbarcode/barcodes/pharmacode/index.js +32 -62
- package/libs/jsbarcode/exceptions/ErrorHandler.js +28 -43
- package/libs/jsbarcode/exceptions/exceptions.js +21 -59
- package/libs/jsbarcode/help/fixOptions.js +3 -9
- package/libs/jsbarcode/help/getOptionsFromElement.js +10 -23
- package/libs/jsbarcode/help/getRenderProperties.js +63 -69
- package/libs/jsbarcode/help/linearizeEncodings.js +8 -13
- package/libs/jsbarcode/help/merge.js +1 -11
- package/libs/jsbarcode/help/optionsFromStrings.js +19 -15
- package/libs/jsbarcode/options/defaults.js +2 -7
- package/libs/jsbarcode/renderers/canvas.js +106 -127
- package/libs/jsbarcode/renderers/index.js +4 -20
- package/libs/jsbarcode/renderers/object.js +7 -23
- package/libs/jsbarcode/renderers/shared.js +32 -39
- package/libs/jsbarcode/renderers/svg.js +136 -154
- package/package.json +1 -1
- package/libs/jsbarcode/barcodes/index.tmp.js +0 -33
|
@@ -1,176 +1,168 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
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; }; }();
|
|
8
|
-
|
|
9
|
-
var _encoder = require('./encoder');
|
|
10
|
-
|
|
11
|
-
var _encoder2 = _interopRequireDefault(_encoder);
|
|
12
|
-
|
|
13
|
-
var _Barcode2 = require('../Barcode.js');
|
|
14
|
-
|
|
15
|
-
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
16
|
-
|
|
17
|
-
var _UPC = require('./UPC.js');
|
|
18
|
-
|
|
19
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
20
|
-
|
|
21
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
22
|
-
|
|
23
|
-
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; }
|
|
24
|
-
|
|
25
|
-
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:
|
|
1
|
+
// Encoding documentation:
|
|
26
2
|
// https://en.wikipedia.org/wiki/Universal_Product_Code#Encoding
|
|
27
3
|
//
|
|
28
4
|
// UPC-E documentation:
|
|
29
5
|
// https://en.wikipedia.org/wiki/Universal_Product_Code#UPC-E
|
|
30
6
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
7
|
+
import encode from './encoder';
|
|
8
|
+
import Barcode from "../Barcode.js";
|
|
9
|
+
import { checksum } from './UPC.js';
|
|
10
|
+
|
|
11
|
+
const EXPANSIONS = [
|
|
12
|
+
"XX00000XXX",
|
|
13
|
+
"XX10000XXX",
|
|
14
|
+
"XX20000XXX",
|
|
15
|
+
"XXX00000XX",
|
|
16
|
+
"XXXX00000X",
|
|
17
|
+
"XXXXX00005",
|
|
18
|
+
"XXXXX00006",
|
|
19
|
+
"XXXXX00007",
|
|
20
|
+
"XXXXX00008",
|
|
21
|
+
"XXXXX00009"
|
|
22
|
+
];
|
|
23
|
+
|
|
24
|
+
const PARITIES = [
|
|
25
|
+
["EEEOOO", "OOOEEE"],
|
|
26
|
+
["EEOEOO", "OOEOEE"],
|
|
27
|
+
["EEOOEO", "OOEEOE"],
|
|
28
|
+
["EEOOOE", "OOEEEO"],
|
|
29
|
+
["EOEEOO", "OEOOEE"],
|
|
30
|
+
["EOOEEO", "OEEOOE"],
|
|
31
|
+
["EOOOEE", "OEEEOO"],
|
|
32
|
+
["EOEOEO", "OEOEOE"],
|
|
33
|
+
["EOEOOE", "OEOEEO"],
|
|
34
|
+
["EOOEOE", "OEEOEO"]
|
|
35
|
+
];
|
|
36
|
+
|
|
37
|
+
class UPCE extends Barcode{
|
|
38
|
+
constructor(data, options){
|
|
42
39
|
// Code may be 6 or 8 digits;
|
|
43
40
|
// A 7 digit code is ambiguous as to whether the extra digit
|
|
44
41
|
// is a UPC-A check or number system digit.
|
|
42
|
+
super(data, options);
|
|
43
|
+
this.isValid = false;
|
|
44
|
+
if(data.search(/^[0-9]{6}$/) !== -1){
|
|
45
|
+
this.middleDigits = data;
|
|
46
|
+
this.upcA = expandToUPCA(data, "0");
|
|
47
|
+
this.text = options.text ||
|
|
48
|
+
`${this.upcA[0]}${data}${this.upcA[this.upcA.length - 1]}`;
|
|
49
|
+
this.isValid = true;
|
|
50
|
+
}
|
|
51
|
+
else if(data.search(/^[01][0-9]{7}$/) !== -1){
|
|
52
|
+
this.middleDigits = data.substring(1, data.length - 1);
|
|
53
|
+
this.upcA = expandToUPCA(this.middleDigits, data[0]);
|
|
45
54
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
_this.upcA = expandToUPCA(data, "0");
|
|
51
|
-
_this.text = options.text || '' + _this.upcA[0] + data + _this.upcA[_this.upcA.length - 1];
|
|
52
|
-
_this.isValid = true;
|
|
53
|
-
} else if (data.search(/^[01][0-9]{7}$/) !== -1) {
|
|
54
|
-
_this.middleDigits = data.substring(1, data.length - 1);
|
|
55
|
-
_this.upcA = expandToUPCA(_this.middleDigits, data[0]);
|
|
56
|
-
|
|
57
|
-
if (_this.upcA[_this.upcA.length - 1] === data[data.length - 1]) {
|
|
58
|
-
_this.isValid = true;
|
|
59
|
-
} else {
|
|
55
|
+
if(this.upcA[this.upcA.length - 1] === data[data.length - 1]){
|
|
56
|
+
this.isValid = true;
|
|
57
|
+
}
|
|
58
|
+
else{
|
|
60
59
|
// checksum mismatch
|
|
61
|
-
return
|
|
60
|
+
return;
|
|
62
61
|
}
|
|
63
|
-
}
|
|
64
|
-
|
|
62
|
+
}
|
|
63
|
+
else{
|
|
64
|
+
return;
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
|
|
67
|
+
this.displayValue = options.displayValue;
|
|
68
68
|
|
|
69
69
|
// Make sure the font is not bigger than the space between the guard bars
|
|
70
|
-
if
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
|
|
70
|
+
if(options.fontSize > options.width * 10){
|
|
71
|
+
this.fontSize = options.width * 10;
|
|
72
|
+
}
|
|
73
|
+
else{
|
|
74
|
+
this.fontSize = options.fontSize;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
// Make the guard bars go down half the way of the text
|
|
77
|
-
|
|
78
|
-
return _this;
|
|
78
|
+
this.guardHeight = options.height + this.fontSize / 2 + options.textMargin;
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
value: function encode() {
|
|
89
|
-
if (this.options.flat) {
|
|
90
|
-
return this.flatEncoding();
|
|
91
|
-
} else {
|
|
92
|
-
return this.guardedEncoding();
|
|
93
|
-
}
|
|
81
|
+
valid(){
|
|
82
|
+
return this.isValid;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
encode(){
|
|
86
|
+
if(this.options.flat){
|
|
87
|
+
return this.flatEncoding();
|
|
94
88
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
value: function flatEncoding() {
|
|
98
|
-
var result = "";
|
|
99
|
-
|
|
100
|
-
result += "101";
|
|
101
|
-
result += this.encodeMiddleDigits();
|
|
102
|
-
result += "010101";
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
data: result,
|
|
106
|
-
text: this.text
|
|
107
|
-
};
|
|
89
|
+
else{
|
|
90
|
+
return this.guardedEncoding();
|
|
108
91
|
}
|
|
109
|
-
}
|
|
110
|
-
key: 'guardedEncoding',
|
|
111
|
-
value: function guardedEncoding() {
|
|
112
|
-
var result = [];
|
|
113
|
-
|
|
114
|
-
// Add the UPC-A number system digit beneath the quiet zone
|
|
115
|
-
if (this.displayValue) {
|
|
116
|
-
result.push({
|
|
117
|
-
data: "00000000",
|
|
118
|
-
text: this.text[0],
|
|
119
|
-
options: { textAlign: "left", fontSize: this.fontSize }
|
|
120
|
-
});
|
|
121
|
-
}
|
|
92
|
+
}
|
|
122
93
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
94
|
+
flatEncoding(){
|
|
95
|
+
var result = "";
|
|
96
|
+
|
|
97
|
+
result += "101";
|
|
98
|
+
result += this.encodeMiddleDigits();
|
|
99
|
+
result += "010101";
|
|
100
|
+
|
|
101
|
+
return {
|
|
102
|
+
data: result,
|
|
103
|
+
text: this.text
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
guardedEncoding(){
|
|
108
|
+
var result = [];
|
|
128
109
|
|
|
129
|
-
|
|
110
|
+
// Add the UPC-A number system digit beneath the quiet zone
|
|
111
|
+
if(this.displayValue){
|
|
130
112
|
result.push({
|
|
131
|
-
data:
|
|
132
|
-
text: this.text
|
|
133
|
-
options: { fontSize: this.fontSize
|
|
113
|
+
data: "00000000",
|
|
114
|
+
text: this.text[0],
|
|
115
|
+
options: {textAlign: "left", fontSize: this.fontSize}
|
|
134
116
|
});
|
|
117
|
+
}
|
|
135
118
|
|
|
136
|
-
|
|
119
|
+
// Add the guard bars
|
|
120
|
+
result.push({
|
|
121
|
+
data: "101",
|
|
122
|
+
options: {height: this.guardHeight}
|
|
123
|
+
});
|
|
124
|
+
|
|
125
|
+
// Add the 6 UPC-E digits
|
|
126
|
+
result.push({
|
|
127
|
+
data: this.encodeMiddleDigits(),
|
|
128
|
+
text: this.text.substring(1, 7),
|
|
129
|
+
options: {fontSize: this.fontSize}
|
|
130
|
+
});
|
|
131
|
+
|
|
132
|
+
// Add the end bits
|
|
133
|
+
result.push({
|
|
134
|
+
data: "010101",
|
|
135
|
+
options: {height: this.guardHeight}
|
|
136
|
+
});
|
|
137
|
+
|
|
138
|
+
// Add the UPC-A check digit beneath the quiet zone
|
|
139
|
+
if(this.displayValue){
|
|
137
140
|
result.push({
|
|
138
|
-
data: "
|
|
139
|
-
|
|
141
|
+
data: "00000000",
|
|
142
|
+
text: this.text[7],
|
|
143
|
+
options: {textAlign: "right", fontSize: this.fontSize}
|
|
140
144
|
});
|
|
141
|
-
|
|
142
|
-
// Add the UPC-A check digit beneath the quiet zone
|
|
143
|
-
if (this.displayValue) {
|
|
144
|
-
result.push({
|
|
145
|
-
data: "00000000",
|
|
146
|
-
text: this.text[7],
|
|
147
|
-
options: { textAlign: "right", fontSize: this.fontSize }
|
|
148
|
-
});
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return result;
|
|
152
145
|
}
|
|
153
|
-
}, {
|
|
154
|
-
key: 'encodeMiddleDigits',
|
|
155
|
-
value: function encodeMiddleDigits() {
|
|
156
|
-
var numberSystem = this.upcA[0];
|
|
157
|
-
var checkDigit = this.upcA[this.upcA.length - 1];
|
|
158
|
-
var parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
|
|
159
|
-
return (0, _encoder2.default)(this.middleDigits, parity);
|
|
160
|
-
}
|
|
161
|
-
}]);
|
|
162
146
|
|
|
163
|
-
|
|
164
|
-
}
|
|
147
|
+
return result;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
encodeMiddleDigits() {
|
|
151
|
+
const numberSystem = this.upcA[0];
|
|
152
|
+
const checkDigit = this.upcA[this.upcA.length - 1];
|
|
153
|
+
const parity = PARITIES[parseInt(checkDigit)][parseInt(numberSystem)];
|
|
154
|
+
return encode(this.middleDigits, parity);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
165
157
|
|
|
166
158
|
function expandToUPCA(middleDigits, numberSystem) {
|
|
167
|
-
|
|
168
|
-
|
|
159
|
+
const lastUpcE = parseInt(middleDigits[middleDigits.length - 1]);
|
|
160
|
+
const expansion = EXPANSIONS[lastUpcE];
|
|
169
161
|
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
for
|
|
173
|
-
|
|
162
|
+
let result = "";
|
|
163
|
+
let digitIndex = 0;
|
|
164
|
+
for(let i = 0; i < expansion.length; i++) {
|
|
165
|
+
let c = expansion[i];
|
|
174
166
|
if (c === 'X') {
|
|
175
167
|
result += middleDigits[digitIndex++];
|
|
176
168
|
} else {
|
|
@@ -178,8 +170,8 @@ function expandToUPCA(middleDigits, numberSystem) {
|
|
|
178
170
|
}
|
|
179
171
|
}
|
|
180
172
|
|
|
181
|
-
result =
|
|
182
|
-
return
|
|
173
|
+
result = `${numberSystem}${result}`;
|
|
174
|
+
return `${result}${checksum(result)}`;
|
|
183
175
|
}
|
|
184
176
|
|
|
185
|
-
|
|
177
|
+
export default UPCE;
|
|
@@ -1,30 +1,41 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
1
|
// Standard start end and middle bits
|
|
7
|
-
|
|
8
|
-
|
|
2
|
+
export const SIDE_BIN = '101';
|
|
3
|
+
export const MIDDLE_BIN = '01010';
|
|
9
4
|
|
|
10
|
-
|
|
11
|
-
'L': [// The L (left) type of encoding
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
'
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
'
|
|
20
|
-
|
|
5
|
+
export const BINARIES = {
|
|
6
|
+
'L': [ // The L (left) type of encoding
|
|
7
|
+
'0001101', '0011001', '0010011', '0111101', '0100011',
|
|
8
|
+
'0110001', '0101111', '0111011', '0110111', '0001011'
|
|
9
|
+
],
|
|
10
|
+
'G': [ // The G type of encoding
|
|
11
|
+
'0100111', '0110011', '0011011', '0100001', '0011101',
|
|
12
|
+
'0111001', '0000101', '0010001', '0001001', '0010111'
|
|
13
|
+
],
|
|
14
|
+
'R': [ // The R (right) type of encoding
|
|
15
|
+
'1110010', '1100110', '1101100', '1000010', '1011100',
|
|
16
|
+
'1001110', '1010000', '1000100', '1001000', '1110100'
|
|
17
|
+
],
|
|
18
|
+
'O': [ // The O (odd) encoding for UPC-E
|
|
19
|
+
'0001101', '0011001', '0010011', '0111101', '0100011',
|
|
20
|
+
'0110001', '0101111', '0111011', '0110111', '0001011'
|
|
21
|
+
],
|
|
22
|
+
'E': [ // The E (even) encoding for UPC-E
|
|
23
|
+
'0100111', '0110011', '0011011', '0100001', '0011101',
|
|
24
|
+
'0111001', '0000101', '0010001', '0001001', '0010111'
|
|
25
|
+
]
|
|
21
26
|
};
|
|
22
27
|
|
|
23
28
|
// Define the EAN-2 structure
|
|
24
|
-
|
|
29
|
+
export const EAN2_STRUCTURE = ['LL', 'LG', 'GL', 'GG'];
|
|
25
30
|
|
|
26
31
|
// Define the EAN-5 structure
|
|
27
|
-
|
|
32
|
+
export const EAN5_STRUCTURE = [
|
|
33
|
+
'GGLLL', 'GLGLL', 'GLLGL', 'GLLLG', 'LGGLL',
|
|
34
|
+
'LLGGL', 'LLLGG', 'LGLGL', 'LGLLG', 'LLGLG'
|
|
35
|
+
];
|
|
28
36
|
|
|
29
37
|
// Define the EAN-13 structure
|
|
30
|
-
|
|
38
|
+
export const EAN13_STRUCTURE = [
|
|
39
|
+
'LLLLLL', 'LLGLGG', 'LLGGLG', 'LLGGGL', 'LGLLGG',
|
|
40
|
+
'LGGLLG', 'LGGGLL', 'LGLGLG', 'LGLGGL', 'LGGLGL'
|
|
41
|
+
];
|
|
@@ -1,27 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _constants = require('./constants');
|
|
1
|
+
import { BINARIES } from './constants';
|
|
8
2
|
|
|
9
3
|
// Encode data string
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
});
|
|
4
|
+
const encode = (data, structure, separator) => {
|
|
5
|
+
let encoded = data
|
|
6
|
+
.split('')
|
|
7
|
+
.map((val, idx) => BINARIES[structure[idx]])
|
|
8
|
+
.map((val, idx) => val ? val[data[idx]] : '');
|
|
16
9
|
|
|
17
10
|
if (separator) {
|
|
18
|
-
|
|
19
|
-
encoded = encoded.map(
|
|
20
|
-
|
|
21
|
-
|
|
11
|
+
const last = data.length - 1;
|
|
12
|
+
encoded = encoded.map((val, idx) => (
|
|
13
|
+
idx < last ? val + separator : val
|
|
14
|
+
));
|
|
22
15
|
}
|
|
23
16
|
|
|
24
17
|
return encoded.join('');
|
|
25
18
|
};
|
|
26
19
|
|
|
27
|
-
|
|
20
|
+
export default encode;
|
|
@@ -1,39 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
var _EAN2 = _interopRequireDefault(_EAN);
|
|
11
|
-
|
|
12
|
-
var _EAN3 = require('./EAN8.js');
|
|
13
|
-
|
|
14
|
-
var _EAN4 = _interopRequireDefault(_EAN3);
|
|
15
|
-
|
|
16
|
-
var _EAN5 = require('./EAN5.js');
|
|
17
|
-
|
|
18
|
-
var _EAN6 = _interopRequireDefault(_EAN5);
|
|
19
|
-
|
|
20
|
-
var _EAN7 = require('./EAN2.js');
|
|
21
|
-
|
|
22
|
-
var _EAN8 = _interopRequireDefault(_EAN7);
|
|
23
|
-
|
|
24
|
-
var _UPC = require('./UPC.js');
|
|
25
|
-
|
|
26
|
-
var _UPC2 = _interopRequireDefault(_UPC);
|
|
27
|
-
|
|
28
|
-
var _UPCE = require('./UPCE.js');
|
|
29
|
-
|
|
30
|
-
var _UPCE2 = _interopRequireDefault(_UPCE);
|
|
31
|
-
|
|
32
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
33
|
-
|
|
34
|
-
exports.EAN13 = _EAN2.default;
|
|
35
|
-
exports.EAN8 = _EAN4.default;
|
|
36
|
-
exports.EAN5 = _EAN6.default;
|
|
37
|
-
exports.EAN2 = _EAN8.default;
|
|
38
|
-
exports.UPC = _UPC2.default;
|
|
39
|
-
exports.UPCE = _UPCE2.default;
|
|
1
|
+
import EAN13 from './EAN13.js';
|
|
2
|
+
import EAN8 from './EAN8.js';
|
|
3
|
+
import EAN5 from './EAN5.js';
|
|
4
|
+
import EAN2 from './EAN2.js';
|
|
5
|
+
import UPC from './UPC.js';
|
|
6
|
+
import UPCE from './UPCE.js';
|
|
7
|
+
|
|
8
|
+
export {EAN13, EAN8, EAN5, EAN2, UPC, UPCE};
|
|
@@ -1,55 +1,22 @@
|
|
|
1
|
-
|
|
1
|
+
import Barcode from "../Barcode.js";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
exports.GenericBarcode = undefined;
|
|
7
|
-
|
|
8
|
-
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; }; }();
|
|
9
|
-
|
|
10
|
-
var _Barcode2 = require("../Barcode.js");
|
|
11
|
-
|
|
12
|
-
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
13
|
-
|
|
14
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
15
|
-
|
|
16
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
17
|
-
|
|
18
|
-
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; }
|
|
19
|
-
|
|
20
|
-
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; }
|
|
21
|
-
|
|
22
|
-
var GenericBarcode = function (_Barcode) {
|
|
23
|
-
_inherits(GenericBarcode, _Barcode);
|
|
24
|
-
|
|
25
|
-
function GenericBarcode(data, options) {
|
|
26
|
-
_classCallCheck(this, GenericBarcode);
|
|
27
|
-
|
|
28
|
-
return _possibleConstructorReturn(this, (GenericBarcode.__proto__ || Object.getPrototypeOf(GenericBarcode)).call(this, data, options)); // Sets this.data and this.text
|
|
3
|
+
class GenericBarcode extends Barcode{
|
|
4
|
+
constructor(data, options){
|
|
5
|
+
super(data, options); // Sets this.data and this.text
|
|
29
6
|
}
|
|
30
7
|
|
|
31
8
|
// Return the corresponding binary numbers for the data provided
|
|
9
|
+
encode(){
|
|
10
|
+
return {
|
|
11
|
+
data: "10101010101010101010101010101010101010101",
|
|
12
|
+
text: this.text
|
|
13
|
+
};
|
|
14
|
+
}
|
|
32
15
|
|
|
16
|
+
// Resturn true/false if the string provided is valid for this encoder
|
|
17
|
+
valid(){
|
|
18
|
+
return true;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
33
21
|
|
|
34
|
-
|
|
35
|
-
key: "encode",
|
|
36
|
-
value: function encode() {
|
|
37
|
-
return {
|
|
38
|
-
data: "10101010101010101010101010101010101010101",
|
|
39
|
-
text: this.text
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Resturn true/false if the string provided is valid for this encoder
|
|
44
|
-
|
|
45
|
-
}, {
|
|
46
|
-
key: "valid",
|
|
47
|
-
value: function valid() {
|
|
48
|
-
return true;
|
|
49
|
-
}
|
|
50
|
-
}]);
|
|
51
|
-
|
|
52
|
-
return GenericBarcode;
|
|
53
|
-
}(_Barcode3.default);
|
|
54
|
-
|
|
55
|
-
exports.GenericBarcode = GenericBarcode;
|
|
22
|
+
export {GenericBarcode};
|
|
@@ -1,69 +1,37 @@
|
|
|
1
|
-
|
|
1
|
+
import { START_BIN, END_BIN, BINARIES } from './constants';
|
|
2
|
+
import Barcode from '../Barcode';
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
4
|
+
class ITF extends Barcode {
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
var _constants = require('./constants');
|
|
10
|
-
|
|
11
|
-
var _Barcode2 = require('../Barcode');
|
|
12
|
-
|
|
13
|
-
var _Barcode3 = _interopRequireDefault(_Barcode2);
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
18
|
-
|
|
19
|
-
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; }
|
|
20
|
-
|
|
21
|
-
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; }
|
|
22
|
-
|
|
23
|
-
var ITF = function (_Barcode) {
|
|
24
|
-
_inherits(ITF, _Barcode);
|
|
25
|
-
|
|
26
|
-
function ITF() {
|
|
27
|
-
_classCallCheck(this, ITF);
|
|
28
|
-
|
|
29
|
-
return _possibleConstructorReturn(this, (ITF.__proto__ || Object.getPrototypeOf(ITF)).apply(this, arguments));
|
|
6
|
+
valid() {
|
|
7
|
+
return this.data.search(/^([0-9]{2})+$/) !== -1;
|
|
30
8
|
}
|
|
31
9
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return _this2.encodePair(pair);
|
|
45
|
-
}).join('');
|
|
46
|
-
|
|
47
|
-
return {
|
|
48
|
-
data: _constants.START_BIN + encoded + _constants.END_BIN,
|
|
49
|
-
text: this.text
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// Calculate the data of a number pair
|
|
54
|
-
|
|
55
|
-
}, {
|
|
56
|
-
key: 'encodePair',
|
|
57
|
-
value: function encodePair(pair) {
|
|
58
|
-
var second = _constants.BINARIES[pair[1]];
|
|
59
|
-
|
|
60
|
-
return _constants.BINARIES[pair[0]].split('').map(function (first, idx) {
|
|
61
|
-
return (first === '1' ? '111' : '1') + (second[idx] === '1' ? '000' : '0');
|
|
62
|
-
}).join('');
|
|
63
|
-
}
|
|
64
|
-
}]);
|
|
10
|
+
encode() {
|
|
11
|
+
// Calculate all the digit pairs
|
|
12
|
+
const encoded = this.data
|
|
13
|
+
.match(/.{2}/g)
|
|
14
|
+
.map(pair => this.encodePair(pair))
|
|
15
|
+
.join('');
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
data: START_BIN + encoded + END_BIN,
|
|
19
|
+
text: this.text
|
|
20
|
+
};
|
|
21
|
+
}
|
|
65
22
|
|
|
66
|
-
|
|
67
|
-
|
|
23
|
+
// Calculate the data of a number pair
|
|
24
|
+
encodePair(pair) {
|
|
25
|
+
const second = BINARIES[pair[1]];
|
|
26
|
+
|
|
27
|
+
return BINARIES[pair[0]]
|
|
28
|
+
.split('')
|
|
29
|
+
.map((first, idx) => (
|
|
30
|
+
(first === '1' ? '111' : '1') +
|
|
31
|
+
(second[idx] === '1' ? '000' : '0')
|
|
32
|
+
))
|
|
33
|
+
.join('');
|
|
34
|
+
}
|
|
35
|
+
}
|
|
68
36
|
|
|
69
|
-
|
|
37
|
+
export default ITF;
|