@progress/kendo-charts 1.19.1 → 1.20.0-dev.202111121622
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/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/chart/chart.js +15 -6
- package/dist/es/chart/constants.js +3 -1
- package/dist/es/chart/pan-and-zoom/mousewheel-zoom.js +8 -4
- package/dist/es/chart/selection.js +41 -1
- package/dist/es/common/mousewheel-delta.js +4 -7
- package/dist/es/core/axis.js +47 -0
- package/dist/es/core/category-axis.js +62 -20
- package/dist/es/core/date-category-axis.js +26 -38
- package/dist/es/core/date-value-axis.js +37 -40
- package/dist/es/core/logarithmic-axis.js +62 -88
- package/dist/es/core/numeric-axis.js +57 -81
- package/dist/es/main.js +1 -0
- package/dist/es/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +103 -0
- package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +51 -0
- package/dist/es/qrcode/encodings/data-modes/data-mode-instances.js +12 -0
- package/dist/es/qrcode/encodings/data-modes/numeric-data-mode.js +49 -0
- package/dist/es/qrcode/encodings/data-modes/qr-data-mode.js +50 -0
- package/dist/es/qrcode/encodings/encoders/iso-encoder.js +29 -0
- package/dist/es/qrcode/encodings/encoders/utf8-encoder.js +91 -0
- package/dist/es/qrcode/encodings/encoding-result.js +16 -0
- package/dist/es/qrcode/encodings/encoding.js +701 -0
- package/dist/es/qrcode/encodings/free-cell-visitor.js +57 -0
- package/dist/es/qrcode/encodings/version-codewords.js +1289 -0
- package/dist/es/qrcode/qrcode.js +403 -0
- package/dist/es/qrcode/utils.js +28 -0
- package/dist/es/qrcode.js +1 -0
- package/dist/es/stock/navigator.js +3 -2
- package/dist/es2015/chart/chart.js +15 -6
- package/dist/es2015/chart/constants.js +3 -1
- package/dist/es2015/chart/pan-and-zoom/mousewheel-zoom.js +6 -4
- package/dist/es2015/chart/selection.js +40 -1
- package/dist/es2015/common/mousewheel-delta.js +4 -7
- package/dist/es2015/core/axis.js +39 -0
- package/dist/es2015/core/category-axis.js +56 -18
- package/dist/es2015/core/date-category-axis.js +27 -36
- package/dist/es2015/core/date-value-axis.js +35 -40
- package/dist/es2015/core/logarithmic-axis.js +52 -83
- package/dist/es2015/core/numeric-axis.js +47 -78
- package/dist/es2015/main.js +1 -0
- package/dist/es2015/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +91 -0
- package/dist/es2015/qrcode/encodings/data-modes/byte-data-mode.js +41 -0
- package/dist/es2015/qrcode/encodings/data-modes/data-mode-instances.js +13 -0
- package/dist/es2015/qrcode/encodings/data-modes/numeric-data-mode.js +39 -0
- package/dist/es2015/qrcode/encodings/data-modes/qr-data-mode.js +44 -0
- package/dist/es2015/qrcode/encodings/encoders/iso-encoder.js +19 -0
- package/dist/es2015/qrcode/encodings/encoders/utf8-encoder.js +83 -0
- package/dist/es2015/qrcode/encodings/encoding-result.js +10 -0
- package/dist/es2015/qrcode/encodings/encoding.js +701 -0
- package/dist/es2015/qrcode/encodings/free-cell-visitor.js +49 -0
- package/dist/es2015/qrcode/encodings/version-codewords.js +1289 -0
- package/dist/es2015/qrcode/qrcode.js +395 -0
- package/dist/es2015/qrcode/utils.js +28 -0
- package/dist/es2015/qrcode.js +1 -0
- package/dist/es2015/stock/navigator.js +3 -2
- package/dist/npm/main.d.ts +1 -0
- package/dist/npm/main.js +3172 -283
- package/dist/npm/qrcode.d.ts +5 -0
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +1 -1
|
@@ -3,8 +3,8 @@ import Axis from './axis';
|
|
|
3
3
|
import AxisLabel from './axis-label';
|
|
4
4
|
import Box from './box';
|
|
5
5
|
|
|
6
|
-
import { BLACK, DEFAULT_PRECISION, COORD_PRECISION
|
|
7
|
-
import { deepExtend, defined, limitValue, round, setDefaultOptions } from '../common';
|
|
6
|
+
import { BLACK, DEFAULT_PRECISION, COORD_PRECISION } from '../common/constants';
|
|
7
|
+
import { deepExtend, defined, limitValue, round, setDefaultOptions, valueOrDefault } from '../common';
|
|
8
8
|
|
|
9
9
|
import autoMajorUnit from './utils/auto-major-unit';
|
|
10
10
|
import autoAxisMin from './utils/auto-axis-min';
|
|
@@ -70,17 +70,13 @@ class NumericAxis extends Axis {
|
|
|
70
70
|
|
|
71
71
|
getTickPositions(unit, skipUnit) {
|
|
72
72
|
const options = this.options;
|
|
73
|
-
const {
|
|
74
|
-
const lineBox = this.lineBox();
|
|
75
|
-
const lineSize = vertical ? lineBox.height() : lineBox.width();
|
|
73
|
+
const { axisDir, axisOrigin, lineBox, lineSize } = this.lineInfo();
|
|
76
74
|
const range = options.max - options.min;
|
|
77
75
|
const scale = lineSize / range;
|
|
78
76
|
const step = unit * scale;
|
|
79
77
|
const divisions = this.getDivisions(unit);
|
|
80
|
-
const dir = (vertical ? -1 : 1) * (reverse ? -1 : 1);
|
|
81
|
-
const startEdge = dir === 1 ? 1 : 2;
|
|
82
78
|
const positions = [];
|
|
83
|
-
let pos = lineBox[
|
|
79
|
+
let pos = lineBox[axisOrigin];
|
|
84
80
|
let skipStep = 0;
|
|
85
81
|
|
|
86
82
|
if (skipUnit) {
|
|
@@ -92,7 +88,7 @@ class NumericAxis extends Axis {
|
|
|
92
88
|
positions.push(round(pos, COORD_PRECISION));
|
|
93
89
|
}
|
|
94
90
|
|
|
95
|
-
pos = pos + step *
|
|
91
|
+
pos = pos + step * axisDir;
|
|
96
92
|
}
|
|
97
93
|
|
|
98
94
|
return positions;
|
|
@@ -108,79 +104,48 @@ class NumericAxis extends Axis {
|
|
|
108
104
|
|
|
109
105
|
getSlot(a, b, limit = false) {
|
|
110
106
|
const options = this.options;
|
|
111
|
-
const {
|
|
112
|
-
const
|
|
113
|
-
const lineBox = this.lineBox();
|
|
114
|
-
const lineStart = lineBox[valueAxis + (reverse ? 2 : 1)];
|
|
115
|
-
const lineSize = vertical ? lineBox.height() : lineBox.width();
|
|
116
|
-
const dir = reverse ? -1 : 1;
|
|
117
|
-
const step = dir * (lineSize / (options.max - options.min));
|
|
118
|
-
const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
|
|
119
|
-
|
|
120
|
-
let start = a;
|
|
121
|
-
let end = b;
|
|
122
|
-
|
|
123
|
-
if (!defined(start)) {
|
|
124
|
-
start = end || 0;
|
|
125
|
-
}
|
|
107
|
+
const { axis, axisDir, lineBox, lineSize, lineStart } = this.lineInfo();
|
|
108
|
+
const step = axisDir * (lineSize / (options.max - options.min));
|
|
126
109
|
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
}
|
|
110
|
+
let start = valueOrDefault(a, b || 0);
|
|
111
|
+
let end = valueOrDefault(b, a || 0);
|
|
130
112
|
|
|
131
113
|
if (limit) {
|
|
132
|
-
start =
|
|
133
|
-
end =
|
|
114
|
+
start = limitValue(start, options.min, options.max);
|
|
115
|
+
end = limitValue(end, options.min, options.max);
|
|
134
116
|
}
|
|
135
117
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (vertical) {
|
|
139
|
-
p1 = options.max - Math.max(start, end);
|
|
140
|
-
p2 = options.max - Math.min(start, end);
|
|
141
|
-
} else {
|
|
142
|
-
p1 = Math.min(start, end) - options.min;
|
|
143
|
-
p2 = Math.max(start, end) - options.min;
|
|
144
|
-
}
|
|
118
|
+
const p1 = Math.min(start, end) - options.min;
|
|
119
|
+
const p2 = Math.max(start, end) - options.min;
|
|
145
120
|
|
|
146
|
-
slotBox
|
|
147
|
-
slotBox[
|
|
121
|
+
const slotBox = new Box(lineBox.x1, lineBox.y1, lineBox.x1, lineBox.y1);
|
|
122
|
+
slotBox[axis + 1] = limitCoordinate(lineStart + step * (axisDir > 0 ? p1 : p2));
|
|
123
|
+
slotBox[axis + 2] = limitCoordinate(lineStart + step * (axisDir > 0 ? p2 : p1));
|
|
148
124
|
|
|
149
125
|
return slotBox;
|
|
150
126
|
}
|
|
151
127
|
|
|
152
128
|
getValue(point) {
|
|
153
129
|
const options = this.options;
|
|
154
|
-
const { vertical, reverse } = options;
|
|
155
130
|
const max = Number(options.max);
|
|
156
131
|
const min = Number(options.min);
|
|
157
|
-
const
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
const dir = reverse ? -1 : 1;
|
|
162
|
-
const offset = dir * (point[valueAxis] - lineStart);
|
|
163
|
-
const step = (max - min) / lineSize;
|
|
164
|
-
const valueOffset = offset * step;
|
|
165
|
-
|
|
166
|
-
if (offset < 0 || offset > lineSize) {
|
|
132
|
+
const offset = this.pointOffset(point);
|
|
133
|
+
const valueOffset = offset * (max - min);
|
|
134
|
+
|
|
135
|
+
if (offset < 0 || offset > 1) {
|
|
167
136
|
return null;
|
|
168
137
|
}
|
|
169
138
|
|
|
170
|
-
const value =
|
|
171
|
-
max - valueOffset :
|
|
172
|
-
min + valueOffset;
|
|
173
|
-
|
|
139
|
+
const value = min + valueOffset;
|
|
174
140
|
return round(value, DEFAULT_PRECISION);
|
|
175
141
|
}
|
|
176
142
|
|
|
177
143
|
translateRange(delta) {
|
|
178
144
|
const options = this.options;
|
|
179
145
|
const { vertical, reverse, max, min } = options;
|
|
180
|
-
const
|
|
181
|
-
const size = vertical ? lineBox.height() : lineBox.width();
|
|
146
|
+
const { lineSize } = this.lineInfo();
|
|
182
147
|
const range = max - min;
|
|
183
|
-
const scale =
|
|
148
|
+
const scale = lineSize / range;
|
|
184
149
|
let offset = round(delta / scale, DEFAULT_PRECISION);
|
|
185
150
|
|
|
186
151
|
if ((vertical || reverse) && !(vertical && reverse )) {
|
|
@@ -194,16 +159,6 @@ class NumericAxis extends Axis {
|
|
|
194
159
|
};
|
|
195
160
|
}
|
|
196
161
|
|
|
197
|
-
scaleRange(delta) {
|
|
198
|
-
const options = this.options;
|
|
199
|
-
const offset = -delta * options.majorUnit;
|
|
200
|
-
|
|
201
|
-
return {
|
|
202
|
-
min: options.min - offset,
|
|
203
|
-
max: options.max + offset
|
|
204
|
-
};
|
|
205
|
-
}
|
|
206
|
-
|
|
207
162
|
labelsCount() {
|
|
208
163
|
return this.getDivisions(this.options.majorUnit);
|
|
209
164
|
}
|
|
@@ -240,18 +195,32 @@ class NumericAxis extends Axis {
|
|
|
240
195
|
}
|
|
241
196
|
}
|
|
242
197
|
|
|
243
|
-
|
|
244
|
-
const
|
|
245
|
-
const
|
|
246
|
-
const
|
|
247
|
-
const
|
|
198
|
+
scaleRange(scale, cursor) {
|
|
199
|
+
const position = Math.abs(this.pointOffset(cursor));
|
|
200
|
+
const delta = (this.options.max - this.options.min) * Math.min(1, scale);
|
|
201
|
+
const minDelta = position * delta;
|
|
202
|
+
const maxDelta = (1 - position) * delta;
|
|
203
|
+
const min = this.options.min + minDelta;
|
|
204
|
+
let max = this.options.max - maxDelta;
|
|
248
205
|
|
|
249
|
-
if (
|
|
250
|
-
|
|
251
|
-
min: min,
|
|
252
|
-
max: max
|
|
253
|
-
};
|
|
206
|
+
if (max - min < MIN_VALUE_RANGE) {
|
|
207
|
+
max = min + MIN_VALUE_RANGE;
|
|
254
208
|
}
|
|
209
|
+
|
|
210
|
+
return {
|
|
211
|
+
min: min,
|
|
212
|
+
max: max
|
|
213
|
+
};
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
zoomRange(scale, cursor) {
|
|
217
|
+
const { totalMin, totalMax } = this;
|
|
218
|
+
const range = this.scaleRange(scale, cursor);
|
|
219
|
+
|
|
220
|
+
return {
|
|
221
|
+
min: limitValue(range.min, totalMin, totalMax),
|
|
222
|
+
max: limitValue(range.max, totalMin, totalMax)
|
|
223
|
+
};
|
|
255
224
|
}
|
|
256
225
|
|
|
257
226
|
isValidRange(min, max) {
|
package/dist/es2015/main.js
CHANGED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { QRDataMode } from './qr-data-mode';
|
|
2
|
+
import { extend } from '../../utils';
|
|
3
|
+
import {
|
|
4
|
+
toBitsString,
|
|
5
|
+
splitInto
|
|
6
|
+
} from '../../utils';
|
|
7
|
+
|
|
8
|
+
export class AlphaNumericQRDataMode extends QRDataMode {
|
|
9
|
+
initProperties() {
|
|
10
|
+
super.initProperties();
|
|
11
|
+
|
|
12
|
+
extend(this, {
|
|
13
|
+
characters: {
|
|
14
|
+
"0": 0,
|
|
15
|
+
"1": 1,
|
|
16
|
+
"2": 2,
|
|
17
|
+
"3": 3,
|
|
18
|
+
"4": 4,
|
|
19
|
+
"5": 5,
|
|
20
|
+
"6": 6,
|
|
21
|
+
"7": 7,
|
|
22
|
+
"8": 8,
|
|
23
|
+
"9": 9,
|
|
24
|
+
"A": 10,
|
|
25
|
+
"B": 11,
|
|
26
|
+
"C": 12,
|
|
27
|
+
"D": 13,
|
|
28
|
+
"E": 14,
|
|
29
|
+
"F": 15,
|
|
30
|
+
"G": 16,
|
|
31
|
+
"H": 17,
|
|
32
|
+
"I": 18,
|
|
33
|
+
"J": 19,
|
|
34
|
+
"K": 20,
|
|
35
|
+
"L": 21,
|
|
36
|
+
"M": 22,
|
|
37
|
+
"N": 23,
|
|
38
|
+
"O": 24,
|
|
39
|
+
"P": 25,
|
|
40
|
+
"Q": 26,
|
|
41
|
+
"R": 27,
|
|
42
|
+
"S": 28,
|
|
43
|
+
"T": 29,
|
|
44
|
+
"U": 30,
|
|
45
|
+
"V": 31,
|
|
46
|
+
"W": 32,
|
|
47
|
+
"X": 33,
|
|
48
|
+
"Y": 34,
|
|
49
|
+
"Z": 35,
|
|
50
|
+
" ": 36,
|
|
51
|
+
"$": 37,
|
|
52
|
+
"%": 38,
|
|
53
|
+
"*": 39,
|
|
54
|
+
"+": 40,
|
|
55
|
+
"-": 41,
|
|
56
|
+
".": 42,
|
|
57
|
+
"/": 43,
|
|
58
|
+
":": 44
|
|
59
|
+
},
|
|
60
|
+
bitsInCharacterCount: [9, 11, 13],
|
|
61
|
+
modeIndicator: "0010"
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
getValue(character) {
|
|
66
|
+
return this.characters[character];
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
encode(str, version) {
|
|
70
|
+
let
|
|
71
|
+
parts = splitInto(str, 2),
|
|
72
|
+
result = this.getModeCountString(str.length, version),
|
|
73
|
+
value;
|
|
74
|
+
let i;
|
|
75
|
+
|
|
76
|
+
for (i = 0; i < parts.length - 1; i++) {
|
|
77
|
+
value = 45 * this.getValue(parts[i].charAt(0)) + this.getValue(parts[i].charAt(1));
|
|
78
|
+
result += toBitsString(value, 11);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
value = parts[i].length === 2 ?
|
|
82
|
+
45 * this.getValue(parts[i].charAt(0)) + this.getValue(parts[i].charAt(1)) :
|
|
83
|
+
this.getValue(parts[i].charAt(0));
|
|
84
|
+
|
|
85
|
+
return result + toBitsString(value, 1 + 5 * parts[i].length);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
getStringBitsLength(inputLength, version) {
|
|
89
|
+
return 4 + this.getBitsCharacterCount(version) + 11 * Math.floor(inputLength / 2) + 6 * (inputLength % 2);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { QRDataMode } from './qr-data-mode';
|
|
2
|
+
import { extend } from '../../utils';
|
|
3
|
+
import {
|
|
4
|
+
toBitsString
|
|
5
|
+
} from '../../utils';
|
|
6
|
+
|
|
7
|
+
export class ByteQRDataMode extends QRDataMode {
|
|
8
|
+
initProperties() {
|
|
9
|
+
super.initProperties();
|
|
10
|
+
|
|
11
|
+
extend(this, {
|
|
12
|
+
bitsInCharacterCount: [8, 16, 16],
|
|
13
|
+
modeIndicator: "0100"
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
getValue(character) {
|
|
18
|
+
let code = character.charCodeAt(0);
|
|
19
|
+
|
|
20
|
+
if (code <= 127 || (160 <= code && code <= 255)) {
|
|
21
|
+
return code;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
throw new Error("Unsupported character: " + character);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
encode(str, version) {
|
|
28
|
+
let mode = this,
|
|
29
|
+
result = mode.getModeCountString(str.length, version);
|
|
30
|
+
|
|
31
|
+
for (let i = 0; i < str.length; i++) {
|
|
32
|
+
result += toBitsString(mode.getValue(str.charAt(i)), 8);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return result;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
getStringBitsLength(inputLength, version) {
|
|
39
|
+
return 4 + this.getBitsCharacterCount(version) + 8 * inputLength;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { NumericQRDataMode } from './numeric-data-mode';
|
|
2
|
+
import { AlphaNumericQRDataMode } from './alpha-numeric-data-mode';
|
|
3
|
+
import { ByteQRDataMode } from './byte-data-mode';
|
|
4
|
+
|
|
5
|
+
const NUMERIC = "numeric";
|
|
6
|
+
const ALPHA_NUMERIC = "alphanumeric";
|
|
7
|
+
const BYTE = "byte";
|
|
8
|
+
|
|
9
|
+
export let DataModeInstances = {
|
|
10
|
+
[NUMERIC]: new NumericQRDataMode(),
|
|
11
|
+
[ALPHA_NUMERIC]: new AlphaNumericQRDataMode(),
|
|
12
|
+
[BYTE]: new ByteQRDataMode()
|
|
13
|
+
};
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { QRDataMode } from './qr-data-mode';
|
|
2
|
+
import { extend } from '../../utils';
|
|
3
|
+
import {
|
|
4
|
+
toBitsString,
|
|
5
|
+
splitInto
|
|
6
|
+
} from '../../utils';
|
|
7
|
+
|
|
8
|
+
export class NumericQRDataMode extends QRDataMode {
|
|
9
|
+
initProperties() {
|
|
10
|
+
super.initProperties();
|
|
11
|
+
|
|
12
|
+
extend(this, {
|
|
13
|
+
bitsInCharacterCount: [10, 12, 14],
|
|
14
|
+
modeIndicator: "0001"
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
getValue(character) {
|
|
19
|
+
return parseInt(character, 10);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
encode(str, version) {
|
|
23
|
+
let mode = this,
|
|
24
|
+
parts = splitInto(str, 3),
|
|
25
|
+
result = mode.getModeCountString(str.length, version);
|
|
26
|
+
let i;
|
|
27
|
+
|
|
28
|
+
for (i = 0; i < parts.length - 1; i++) {
|
|
29
|
+
result += toBitsString(parts[i], 10);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return result + toBitsString(parts[i], 1 + 3 * parts[i].length);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getStringBitsLength(inputLength, version) {
|
|
36
|
+
let mod3 = inputLength % 3;
|
|
37
|
+
return 4 + this.getBitsCharacterCount(version) + 10 * Math.floor(inputLength / 3) + 3 * mod3 + (mod3 === 0 ? 0 : 1);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { Class } from '../../../common';
|
|
2
|
+
import { extend } from '../../utils';
|
|
3
|
+
import {
|
|
4
|
+
toBitsString
|
|
5
|
+
} from '../../utils';
|
|
6
|
+
|
|
7
|
+
export class QRDataMode extends Class {
|
|
8
|
+
constructor() {
|
|
9
|
+
super();
|
|
10
|
+
|
|
11
|
+
this.initProperties();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
initProperties() {
|
|
15
|
+
extend(this, {
|
|
16
|
+
modeIndicator: "",
|
|
17
|
+
bitsInCharacterCount: []
|
|
18
|
+
});
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
getVersionIndex(version) {
|
|
22
|
+
if (version < 10) {
|
|
23
|
+
return 0;
|
|
24
|
+
} else if (version > 26) {
|
|
25
|
+
return 2;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return 1;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
getBitsCharacterCount(version) {
|
|
32
|
+
return this.bitsInCharacterCount[this.getVersionIndex(version || 40)];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
getModeCountString(length, version) {
|
|
36
|
+
return this.modeIndicator + toBitsString(length, this.getBitsCharacterCount(version));
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
encode() { }
|
|
40
|
+
|
|
41
|
+
getStringBitsLength() { }
|
|
42
|
+
|
|
43
|
+
getValue() { }
|
|
44
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Class } from '../../../common';
|
|
2
|
+
import { EncodingResult } from '../encoding-result';
|
|
3
|
+
import {
|
|
4
|
+
getModes,
|
|
5
|
+
getVersion,
|
|
6
|
+
getDataCodewordsCount,
|
|
7
|
+
getDataString
|
|
8
|
+
} from '../encoding';
|
|
9
|
+
|
|
10
|
+
export class IsoEncoder extends Class {
|
|
11
|
+
getEncodingResult(inputString, errorCorrectionLevel) {
|
|
12
|
+
let modes = getModes(inputString),
|
|
13
|
+
dataCodewordsCount = getDataCodewordsCount(modes),
|
|
14
|
+
version = getVersion(dataCodewordsCount, errorCorrectionLevel),
|
|
15
|
+
dataString = getDataString(modes, version);
|
|
16
|
+
|
|
17
|
+
return new EncodingResult(dataString, version);
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import { Class } from '../../../common';
|
|
2
|
+
import { EncodingResult } from '../encoding-result';
|
|
3
|
+
import { DataModeInstances } from '../data-modes/data-mode-instances';
|
|
4
|
+
import { extend } from '../../utils';
|
|
5
|
+
import { toBitsString } from '../../utils';
|
|
6
|
+
import { getVersion } from '../encoding';
|
|
7
|
+
|
|
8
|
+
const BYTE = "byte";
|
|
9
|
+
|
|
10
|
+
export class Utf8Encoder extends Class {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
|
+
|
|
14
|
+
this.initProperties();
|
|
15
|
+
|
|
16
|
+
this.mode = DataModeInstances[this.encodingMode];
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
initProperties() {
|
|
20
|
+
extend(this, {
|
|
21
|
+
encodingMode: BYTE,
|
|
22
|
+
utfBOM: "111011111011101110111111",
|
|
23
|
+
initialModeCountStringLength: 20,
|
|
24
|
+
ranges: [128, 2048, 65536, 2097152, 67108864]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
getEncodingResult(inputString, errorCorrectionLevel) {
|
|
29
|
+
let data = this.encode(inputString),
|
|
30
|
+
dataCodewordsCount = this.getDataCodewordsCount(data),
|
|
31
|
+
version = getVersion(dataCodewordsCount, errorCorrectionLevel),
|
|
32
|
+
dataString = this.mode.getModeCountString(data.length / 8, version) + data;
|
|
33
|
+
|
|
34
|
+
return new EncodingResult(dataString, version);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
getDataCodewordsCount(data) {
|
|
38
|
+
let dataLength = data.length,
|
|
39
|
+
dataCodewordsCount = Math.ceil((this.initialModeCountStringLength + dataLength) / 8);
|
|
40
|
+
|
|
41
|
+
return dataCodewordsCount;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
encode(str) {
|
|
45
|
+
let result = this.utfBOM;
|
|
46
|
+
|
|
47
|
+
for (let i = 0; i < str.length; i++) {
|
|
48
|
+
result += this.encodeCharacter(str.charCodeAt(i));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
return result;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
encodeCharacter(code) {
|
|
55
|
+
let bytesCount = this.getBytesCount(code),
|
|
56
|
+
bc = bytesCount - 1,
|
|
57
|
+
result = "";
|
|
58
|
+
|
|
59
|
+
if (bytesCount === 1) {
|
|
60
|
+
result = toBitsString(code, 8);
|
|
61
|
+
} else {
|
|
62
|
+
let significantOnes = 8 - bytesCount;
|
|
63
|
+
|
|
64
|
+
for (let i = 0; i < bc; i++) {
|
|
65
|
+
result = toBitsString(code >> (i * 6) & 63 | 128, 8) + result;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
result = ((code >> bc * 6) | ((255 >> significantOnes) << significantOnes)).toString(2) + result;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return result;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
getBytesCount(code) {
|
|
75
|
+
let ranges = this.ranges;
|
|
76
|
+
|
|
77
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
78
|
+
if (code < ranges[i]) {
|
|
79
|
+
return i + 1;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|