yh-hiprint 2.3.6 → 2.4.1
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/hiprint.bundle.js +11 -1
- package/libs/jquery.js +1 -0
- package/libs/jsbarcode/JsBarcode.js +64 -72
- 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,33 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
var _GenericBarcode = require('./GenericBarcode/');
|
|
22
|
-
|
|
23
|
-
exports.default = {
|
|
24
|
-
CODE39: _CODE.CODE39,
|
|
25
|
-
CODE128: _CODE2.CODE128, CODE128A: _CODE2.CODE128A, CODE128B: _CODE2.CODE128B, CODE128C: _CODE2.CODE128C,
|
|
26
|
-
EAN13: _EAN_UPC.EAN13, EAN8: _EAN_UPC.EAN8, EAN5: _EAN_UPC.EAN5, EAN2: _EAN_UPC.EAN2, UPC: _EAN_UPC.UPC, UPCE: _EAN_UPC.UPCE,
|
|
27
|
-
ITF14: _ITF.ITF14,
|
|
28
|
-
ITF: _ITF.ITF,
|
|
29
|
-
MSI: _MSI.MSI, MSI10: _MSI.MSI10, MSI11: _MSI.MSI11, MSI1010: _MSI.MSI1010, MSI1110: _MSI.MSI1110,
|
|
30
|
-
pharmacode: _pharmacode.pharmacode,
|
|
31
|
-
codabar: _codabar.codabar,
|
|
32
|
-
GenericBarcode: _GenericBarcode.GenericBarcode
|
|
33
|
-
};
|
|
1
|
+
import {CODE39} from './CODE39/';
|
|
2
|
+
import {CODE128, CODE128A, CODE128B, CODE128C} from './CODE128/';
|
|
3
|
+
import {EAN13, EAN8, EAN5, EAN2, UPC, UPCE} from './EAN_UPC/';
|
|
4
|
+
import {ITF, ITF14} from './ITF/';
|
|
5
|
+
import {MSI, MSI10, MSI11, MSI1010, MSI1110} from './MSI/';
|
|
6
|
+
import {pharmacode} from './pharmacode/';
|
|
7
|
+
import {codabar} from './codabar';
|
|
8
|
+
import {GenericBarcode} from './GenericBarcode/';
|
|
9
|
+
|
|
10
|
+
export default {
|
|
11
|
+
CODE39,
|
|
12
|
+
CODE128, CODE128A, CODE128B, CODE128C,
|
|
13
|
+
EAN13, EAN8, EAN5, EAN2, UPC, UPCE,
|
|
14
|
+
ITF14,
|
|
15
|
+
ITF,
|
|
16
|
+
MSI, MSI10, MSI11, MSI1010, MSI1110,
|
|
17
|
+
pharmacode,
|
|
18
|
+
codabar,
|
|
19
|
+
GenericBarcode
|
|
20
|
+
};
|
|
@@ -1,73 +1,43 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.pharmacode = 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; } // Encoding documentation
|
|
1
|
+
// Encoding documentation
|
|
21
2
|
// http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf
|
|
22
3
|
|
|
23
|
-
|
|
24
|
-
_inherits(pharmacode, _Barcode);
|
|
4
|
+
import Barcode from "../Barcode.js";
|
|
25
5
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
_this.number = parseInt(data, 10);
|
|
32
|
-
return _this;
|
|
6
|
+
class pharmacode extends Barcode{
|
|
7
|
+
constructor(data, options){
|
|
8
|
+
super(data, options);
|
|
9
|
+
this.number = parseInt(data, 10);
|
|
33
10
|
}
|
|
34
11
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
var z = this.number;
|
|
39
|
-
var result = "";
|
|
12
|
+
encode(){
|
|
13
|
+
var z = this.number;
|
|
14
|
+
var result = "";
|
|
40
15
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
z = (z - 2) / 2;
|
|
48
|
-
} else {
|
|
49
|
-
// Odd
|
|
50
|
-
result = "100" + result;
|
|
51
|
-
z = (z - 1) / 2;
|
|
52
|
-
}
|
|
16
|
+
// http://i.imgur.com/RMm4UDJ.png
|
|
17
|
+
// (source: http://www.gomaro.ch/ftproot/Laetus_PHARMA-CODE.pdf, page: 34)
|
|
18
|
+
while(!isNaN(z) && z != 0){
|
|
19
|
+
if(z % 2 === 0){ // Even
|
|
20
|
+
result = "11100" + result;
|
|
21
|
+
z = (z - 2) / 2;
|
|
53
22
|
}
|
|
23
|
+
else{ // Odd
|
|
24
|
+
result = "100" + result;
|
|
25
|
+
z = (z - 1) / 2;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
54
28
|
|
|
55
|
-
|
|
56
|
-
|
|
29
|
+
// Remove the two last zeroes
|
|
30
|
+
result = result.slice(0, -2);
|
|
57
31
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
}, {
|
|
64
|
-
key: "valid",
|
|
65
|
-
value: function valid() {
|
|
66
|
-
return this.number >= 3 && this.number <= 131070;
|
|
67
|
-
}
|
|
68
|
-
}]);
|
|
32
|
+
return {
|
|
33
|
+
data: result,
|
|
34
|
+
text: this.text
|
|
35
|
+
};
|
|
36
|
+
}
|
|
69
37
|
|
|
70
|
-
|
|
71
|
-
|
|
38
|
+
valid(){
|
|
39
|
+
return this.number >= 3 && this.number <= 131070;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
72
42
|
|
|
73
|
-
|
|
43
|
+
export {pharmacode};
|
|
@@ -1,54 +1,39 @@
|
|
|
1
|
-
"use strict";
|
|
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
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
10
|
-
|
|
11
1
|
/*eslint no-console: 0 */
|
|
12
2
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
_classCallCheck(this, ErrorHandler);
|
|
16
|
-
|
|
3
|
+
class ErrorHandler{
|
|
4
|
+
constructor(api){
|
|
17
5
|
this.api = api;
|
|
18
6
|
}
|
|
19
7
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
throw e.message;
|
|
29
|
-
}
|
|
30
|
-
} else {
|
|
31
|
-
throw e;
|
|
8
|
+
handleCatch(e){
|
|
9
|
+
// If babel supported extending of Error in a correct way instanceof would be used here
|
|
10
|
+
if(e.name === "InvalidInputException"){
|
|
11
|
+
if(this.api._options.valid !== this.api._defaults.valid){
|
|
12
|
+
this.api._options.valid(false);
|
|
13
|
+
}
|
|
14
|
+
else{
|
|
15
|
+
throw e.message;
|
|
32
16
|
}
|
|
33
|
-
|
|
34
|
-
this.api.render = function () {};
|
|
35
17
|
}
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
var result = func.apply(undefined, arguments);
|
|
41
|
-
this.api._options.valid(true);
|
|
42
|
-
return result;
|
|
43
|
-
} catch (e) {
|
|
44
|
-
this.handleCatch(e);
|
|
18
|
+
else{
|
|
19
|
+
throw e;
|
|
20
|
+
}
|
|
45
21
|
|
|
46
|
-
|
|
47
|
-
|
|
22
|
+
this.api.render = function(){};
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
wrapBarcodeCall(func){
|
|
26
|
+
try{
|
|
27
|
+
var result = func(...arguments);
|
|
28
|
+
this.api._options.valid(true);
|
|
29
|
+
return result;
|
|
48
30
|
}
|
|
49
|
-
|
|
31
|
+
catch(e){
|
|
32
|
+
this.handleCatch(e);
|
|
50
33
|
|
|
51
|
-
|
|
52
|
-
}
|
|
34
|
+
return this.api;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
}
|
|
53
38
|
|
|
54
|
-
|
|
39
|
+
export default ErrorHandler;
|
|
@@ -1,67 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
class InvalidInputException extends Error{
|
|
2
|
+
constructor(symbology, input) {
|
|
3
|
+
super();
|
|
4
|
+
this.name = "InvalidInputException";
|
|
2
5
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
+
this.symbology = symbology;
|
|
7
|
+
this.input = input;
|
|
6
8
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
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; }
|
|
10
|
-
|
|
11
|
-
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; }
|
|
12
|
-
|
|
13
|
-
var InvalidInputException = function (_Error) {
|
|
14
|
-
_inherits(InvalidInputException, _Error);
|
|
15
|
-
|
|
16
|
-
function InvalidInputException(symbology, input) {
|
|
17
|
-
_classCallCheck(this, InvalidInputException);
|
|
18
|
-
|
|
19
|
-
var _this = _possibleConstructorReturn(this, (InvalidInputException.__proto__ || Object.getPrototypeOf(InvalidInputException)).call(this));
|
|
20
|
-
|
|
21
|
-
_this.name = "InvalidInputException";
|
|
22
|
-
|
|
23
|
-
_this.symbology = symbology;
|
|
24
|
-
_this.input = input;
|
|
25
|
-
|
|
26
|
-
_this.message = '"' + _this.input + '" is not a valid input for ' + _this.symbology;
|
|
27
|
-
return _this;
|
|
9
|
+
this.message = '"' + this.input + '" is not a valid input for ' + this.symbology;
|
|
28
10
|
}
|
|
11
|
+
}
|
|
29
12
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
function InvalidElementException() {
|
|
37
|
-
_classCallCheck(this, InvalidElementException);
|
|
38
|
-
|
|
39
|
-
var _this2 = _possibleConstructorReturn(this, (InvalidElementException.__proto__ || Object.getPrototypeOf(InvalidElementException)).call(this));
|
|
40
|
-
|
|
41
|
-
_this2.name = "InvalidElementException";
|
|
42
|
-
_this2.message = "Not supported type to render on";
|
|
43
|
-
return _this2;
|
|
13
|
+
class InvalidElementException extends Error{
|
|
14
|
+
constructor() {
|
|
15
|
+
super();
|
|
16
|
+
this.name = "InvalidElementException";
|
|
17
|
+
this.message = "Not supported type to render on";
|
|
44
18
|
}
|
|
19
|
+
}
|
|
45
20
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
function NoElementException() {
|
|
53
|
-
_classCallCheck(this, NoElementException);
|
|
54
|
-
|
|
55
|
-
var _this3 = _possibleConstructorReturn(this, (NoElementException.__proto__ || Object.getPrototypeOf(NoElementException)).call(this));
|
|
56
|
-
|
|
57
|
-
_this3.name = "NoElementException";
|
|
58
|
-
_this3.message = "No element to render on.";
|
|
59
|
-
return _this3;
|
|
21
|
+
class NoElementException extends Error{
|
|
22
|
+
constructor() {
|
|
23
|
+
super();
|
|
24
|
+
this.name = "NoElementException";
|
|
25
|
+
this.message = "No element to render on.";
|
|
60
26
|
}
|
|
27
|
+
}
|
|
61
28
|
|
|
62
|
-
|
|
63
|
-
}(Error);
|
|
64
|
-
|
|
65
|
-
exports.InvalidInputException = InvalidInputException;
|
|
66
|
-
exports.InvalidElementException = InvalidElementException;
|
|
67
|
-
exports.NoElementException = NoElementException;
|
|
29
|
+
export {InvalidInputException, InvalidElementException, NoElementException};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
export default fixOptions;
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = fixOptions;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
function fixOptions(options) {
|
|
3
|
+
function fixOptions(options){
|
|
10
4
|
// Fix the margins
|
|
11
5
|
options.marginTop = options.marginTop || options.margin;
|
|
12
6
|
options.marginBottom = options.marginBottom || options.margin;
|
|
@@ -14,4 +8,4 @@ function fixOptions(options) {
|
|
|
14
8
|
options.marginLeft = options.marginLeft || options.margin;
|
|
15
9
|
|
|
16
10
|
return options;
|
|
17
|
-
}
|
|
11
|
+
}
|
|
@@ -1,30 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import optionsFromStrings from "./optionsFromStrings.js";
|
|
2
|
+
import defaults from "../options/defaults.js";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _optionsFromStrings = require("./optionsFromStrings.js");
|
|
8
|
-
|
|
9
|
-
var _optionsFromStrings2 = _interopRequireDefault(_optionsFromStrings);
|
|
10
|
-
|
|
11
|
-
var _defaults = require("../options/defaults.js");
|
|
12
|
-
|
|
13
|
-
var _defaults2 = _interopRequireDefault(_defaults);
|
|
14
|
-
|
|
15
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
16
|
-
|
|
17
|
-
function getOptionsFromElement(element) {
|
|
4
|
+
function getOptionsFromElement(element){
|
|
18
5
|
var options = {};
|
|
19
|
-
for
|
|
20
|
-
if
|
|
6
|
+
for(var property in defaults){
|
|
7
|
+
if(defaults.hasOwnProperty(property)){
|
|
21
8
|
// jsbarcode-*
|
|
22
|
-
if
|
|
9
|
+
if(element.hasAttribute("jsbarcode-" + property.toLowerCase())){
|
|
23
10
|
options[property] = element.getAttribute("jsbarcode-" + property.toLowerCase());
|
|
24
11
|
}
|
|
25
12
|
|
|
26
13
|
// data-*
|
|
27
|
-
if
|
|
14
|
+
if(element.hasAttribute("data-" + property.toLowerCase())){
|
|
28
15
|
options[property] = element.getAttribute("data-" + property.toLowerCase());
|
|
29
16
|
}
|
|
30
17
|
}
|
|
@@ -32,10 +19,10 @@ function getOptionsFromElement(element) {
|
|
|
32
19
|
|
|
33
20
|
options["value"] = element.getAttribute("jsbarcode-value") || element.getAttribute("data-value");
|
|
34
21
|
|
|
35
|
-
|
|
36
|
-
options = (
|
|
22
|
+
// Since all atributes are string they need to be converted to integers
|
|
23
|
+
options = optionsFromStrings(options);
|
|
37
24
|
|
|
38
25
|
return options;
|
|
39
26
|
}
|
|
40
27
|
|
|
41
|
-
|
|
28
|
+
export default getOptionsFromElement;
|
|
@@ -1,24 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; /* global HTMLImageElement */
|
|
1
|
+
/* global HTMLImageElement */
|
|
8
2
|
/* global HTMLCanvasElement */
|
|
9
3
|
/* global SVGElement */
|
|
10
4
|
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
var _getOptionsFromElement2 = _interopRequireDefault(_getOptionsFromElement);
|
|
14
|
-
|
|
15
|
-
var _renderers = require("../renderers");
|
|
16
|
-
|
|
17
|
-
var _renderers2 = _interopRequireDefault(_renderers);
|
|
5
|
+
import getOptionsFromElement from "./getOptionsFromElement.js";
|
|
6
|
+
import renderers from "../renderers";
|
|
18
7
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
8
|
+
import {InvalidElementException} from "../exceptions/exceptions.js";
|
|
22
9
|
|
|
23
10
|
// Takes an element and returns an object with information about how
|
|
24
11
|
// it should be rendered
|
|
@@ -31,78 +18,85 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { de
|
|
|
31
18
|
// options (optional): Options that can be defined in the element
|
|
32
19
|
// }
|
|
33
20
|
|
|
34
|
-
function getRenderProperties(element)
|
|
21
|
+
function getRenderProperties(element){
|
|
35
22
|
// If the element is a string, query select call again
|
|
36
|
-
if
|
|
23
|
+
if(typeof element === "string"){
|
|
37
24
|
return querySelectedRenderProperties(element);
|
|
38
25
|
}
|
|
39
26
|
// If element is array. Recursivly call with every object in the array
|
|
40
|
-
else if
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
}
|
|
45
|
-
return returnArray;
|
|
27
|
+
else if(Array.isArray(element)){
|
|
28
|
+
var returnArray = [];
|
|
29
|
+
for(let i = 0; i < element.length; i++){
|
|
30
|
+
returnArray.push(getRenderProperties(element[i]));
|
|
46
31
|
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
32
|
+
return returnArray;
|
|
33
|
+
}
|
|
34
|
+
// If element, render on canvas and set the uri as src
|
|
35
|
+
else if(typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLImageElement){
|
|
36
|
+
return newCanvasRenderProperties(element);
|
|
37
|
+
}
|
|
38
|
+
// If SVG
|
|
39
|
+
else if(
|
|
40
|
+
(element && element.nodeName && element.nodeName.toLowerCase() === 'svg') ||
|
|
41
|
+
(typeof SVGElement !== 'undefined' && element instanceof SVGElement)
|
|
42
|
+
){
|
|
43
|
+
return {
|
|
44
|
+
element: element,
|
|
45
|
+
options: getOptionsFromElement(element),
|
|
46
|
+
renderer: renderers.SVGRenderer
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
// If canvas (in browser)
|
|
50
|
+
else if(typeof HTMLCanvasElement !== 'undefined' && element instanceof HTMLCanvasElement){
|
|
51
|
+
return {
|
|
52
|
+
element: element,
|
|
53
|
+
options: getOptionsFromElement(element),
|
|
54
|
+
renderer: renderers.CanvasRenderer
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
// If canvas (in node)
|
|
58
|
+
else if(element && element.getContext){
|
|
59
|
+
return {
|
|
60
|
+
element: element,
|
|
61
|
+
renderer: renderers.CanvasRenderer
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
else if(element && typeof element === 'object' && !element.nodeName) {
|
|
65
|
+
return {
|
|
66
|
+
element: element,
|
|
67
|
+
renderer: renderers.ObjectRenderer
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
else{
|
|
71
|
+
throw new InvalidElementException();
|
|
72
|
+
}
|
|
81
73
|
}
|
|
82
74
|
|
|
83
|
-
function querySelectedRenderProperties(string)
|
|
75
|
+
function querySelectedRenderProperties(string){
|
|
84
76
|
var selector = document.querySelectorAll(string);
|
|
85
|
-
if
|
|
77
|
+
if(selector.length === 0){
|
|
86
78
|
return undefined;
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
|
|
79
|
+
}
|
|
80
|
+
else{
|
|
81
|
+
let returnArray = [];
|
|
82
|
+
for(let i = 0; i < selector.length; i++){
|
|
90
83
|
returnArray.push(getRenderProperties(selector[i]));
|
|
91
84
|
}
|
|
92
85
|
return returnArray;
|
|
93
86
|
}
|
|
94
87
|
}
|
|
95
88
|
|
|
96
|
-
|
|
89
|
+
|
|
90
|
+
function newCanvasRenderProperties(imgElement){
|
|
97
91
|
var canvas = document.createElement('canvas');
|
|
98
92
|
return {
|
|
99
93
|
element: canvas,
|
|
100
|
-
options: (
|
|
101
|
-
renderer:
|
|
102
|
-
afterRender: function
|
|
94
|
+
options: getOptionsFromElement(imgElement),
|
|
95
|
+
renderer: renderers.CanvasRenderer,
|
|
96
|
+
afterRender: function(){
|
|
103
97
|
imgElement.setAttribute("src", canvas.toDataURL());
|
|
104
98
|
}
|
|
105
99
|
};
|
|
106
100
|
}
|
|
107
101
|
|
|
108
|
-
|
|
102
|
+
export default getRenderProperties;
|
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = linearizeEncodings;
|
|
1
|
+
export default linearizeEncodings;
|
|
7
2
|
|
|
8
3
|
// Encodings can be nestled like [[1-1, 1-2], 2, [3-1, 3-2]
|
|
9
4
|
// Convert to [1-1, 1-2, 2, 3-1, 3-2]
|
|
10
|
-
|
|
11
|
-
function linearizeEncodings(encodings) {
|
|
5
|
+
function linearizeEncodings(encodings){
|
|
12
6
|
var linearEncodings = [];
|
|
13
|
-
function nextLevel(encoded)
|
|
14
|
-
if
|
|
15
|
-
for
|
|
7
|
+
function nextLevel(encoded){
|
|
8
|
+
if(Array.isArray(encoded)){
|
|
9
|
+
for(let i = 0; i < encoded.length; i++){
|
|
16
10
|
nextLevel(encoded[i]);
|
|
17
11
|
}
|
|
18
|
-
}
|
|
12
|
+
}
|
|
13
|
+
else{
|
|
19
14
|
encoded.text = encoded.text || "";
|
|
20
15
|
encoded.data = encoded.data || "";
|
|
21
16
|
linearEncodings.push(encoded);
|
|
@@ -24,4 +19,4 @@ function linearizeEncodings(encodings) {
|
|
|
24
19
|
nextLevel(encodings);
|
|
25
20
|
|
|
26
21
|
return linearEncodings;
|
|
27
|
-
}
|
|
22
|
+
}
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
|
|
7
|
-
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
|
|
8
|
-
|
|
9
|
-
exports.default = function (old, replaceObj) {
|
|
10
|
-
return _extends({}, old, replaceObj);
|
|
11
|
-
};
|
|
1
|
+
export default (old, replaceObj) => ({ ...old, ...replaceObj });
|