@progress/kendo-charts 2.7.2-dev.202502101310 → 2.7.2-develop.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/dist/cdn/js/kendo-charts.js +1 -1
- package/dist/cdn/main.js +1 -1
- package/dist/es/barcode/barcode-validator.js +10 -12
- package/dist/es/barcode/barcode.js +84 -96
- package/dist/es/barcode/encodings/code11.js +41 -57
- package/dist/es/barcode/encodings/code128.js +222 -354
- package/dist/es/barcode/encodings/code39-extended.js +20 -34
- package/dist/es/barcode/encodings/code39.js +49 -75
- package/dist/es/barcode/encodings/code93-extended.js +12 -24
- package/dist/es/barcode/encodings/code93.js +52 -70
- package/dist/es/barcode/encodings/ean13.js +28 -42
- package/dist/es/barcode/encodings/ean8.js +8 -18
- package/dist/es/barcode/encodings/encoding.js +18 -24
- package/dist/es/barcode/encodings/main.js +13 -10
- package/dist/es/barcode/encodings/msi.js +56 -112
- package/dist/es/barcode/encodings/postnet.js +31 -45
- package/dist/es/barcode/surface-size.js +2 -2
- package/dist/es/chart/aggregates/aggregates.js +23 -23
- package/dist/es/chart/aggregates/default-aggregates.js +10 -18
- package/dist/es/chart/aggregates/series-aggregator.js +42 -54
- package/dist/es/chart/animations/bar-chart-animation.js +15 -26
- package/dist/es/chart/animations/bubble-animation.js +7 -17
- package/dist/es/chart/animations/clip-animation.js +13 -23
- package/dist/es/chart/animations/fade-in-animation.js +6 -16
- package/dist/es/chart/animations/pie-animation.js +6 -16
- package/dist/es/chart/api-elements/chart-axis.js +14 -22
- package/dist/es/chart/api-elements/chart-pane.js +10 -8
- package/dist/es/chart/api-elements/chart-plotarea.js +4 -10
- package/dist/es/chart/api-elements/find-axis-by-name.js +1 -1
- package/dist/es/chart/area-chart/area-chart.js +46 -60
- package/dist/es/chart/area-chart/area-segment.js +46 -52
- package/dist/es/chart/area-chart/spline-area-segment.js +12 -21
- package/dist/es/chart/area-chart/step-area-segment.js +6 -15
- package/dist/es/chart/axis-group-range-tracker.js +14 -20
- package/dist/es/chart/bar-chart/bar-chart.js +65 -80
- package/dist/es/chart/bar-chart/bar-label.js +25 -32
- package/dist/es/chart/bar-chart/bar.js +76 -91
- package/dist/es/chart/box-plot-chart/box-plot-chart.js +33 -48
- package/dist/es/chart/box-plot-chart/box-plot.js +55 -68
- package/dist/es/chart/box-plot-chart/vertical-box-plot.js +13 -23
- package/dist/es/chart/bubble-chart/bubble-chart.js +51 -64
- package/dist/es/chart/bubble-chart/bubble.js +21 -27
- package/dist/es/chart/bullet-chart/bullet-chart.js +45 -57
- package/dist/es/chart/bullet-chart/bullet.js +48 -57
- package/dist/es/chart/bullet-chart/target.js +1 -11
- package/dist/es/chart/candlestick-chart/candlestick-chart.js +41 -55
- package/dist/es/chart/candlestick-chart/candlestick.js +60 -69
- package/dist/es/chart/categorical-chart.js +178 -206
- package/dist/es/chart/chart-container.js +30 -39
- package/dist/es/chart/chart.js +641 -701
- package/dist/es/chart/constants.js +103 -103
- package/dist/es/chart/crosshair/crosshair-tooltip.js +22 -34
- package/dist/es/chart/crosshair/crosshair.js +39 -47
- package/dist/es/chart/donut-chart/donut-chart.js +36 -48
- package/dist/es/chart/donut-chart/donut-segment.js +12 -24
- package/dist/es/chart/error-bars/categorical-error-bar.js +5 -15
- package/dist/es/chart/error-bars/error-bar-base.js +37 -49
- package/dist/es/chart/error-bars/error-range-calculator.js +46 -56
- package/dist/es/chart/error-bars/scatter-error-bar.js +6 -16
- package/dist/es/chart/funnel-chart/funnel-chart.js +86 -103
- package/dist/es/chart/funnel-chart/funnel-segment.js +46 -54
- package/dist/es/chart/funnel-chart/pyramid-chart.js +5 -11
- package/dist/es/chart/heatmap-chart/color-scale.js +7 -9
- package/dist/es/chart/heatmap-chart/heatmap-chart.js +87 -110
- package/dist/es/chart/heatmap-chart/heatmap-point.js +72 -78
- package/dist/es/chart/highlight.js +26 -36
- package/dist/es/chart/layout/cluster-layout.js +16 -25
- package/dist/es/chart/layout/radar-cluster-layout.js +15 -24
- package/dist/es/chart/layout/radar-stack-layout.js +10 -22
- package/dist/es/chart/layout/stack-wrap.js +12 -24
- package/dist/es/chart/layout/utils.js +2 -2
- package/dist/es/chart/legend/legend-item-line-area.js +8 -19
- package/dist/es/chart/legend/legend-item-line.js +21 -31
- package/dist/es/chart/legend/legend-item-marker.js +18 -28
- package/dist/es/chart/legend/legend-item-square.js +8 -18
- package/dist/es/chart/legend/legend-item.js +91 -105
- package/dist/es/chart/legend/legend-layout.js +18 -25
- package/dist/es/chart/legend/legend.js +68 -92
- package/dist/es/chart/line-chart/line-chart.js +35 -48
- package/dist/es/chart/line-chart/line-point.js +90 -103
- package/dist/es/chart/line-chart/line-segment.js +23 -34
- package/dist/es/chart/line-chart/spline-segment.js +10 -20
- package/dist/es/chart/line-chart/step-line-mixin.js +14 -17
- package/dist/es/chart/line-chart/step-line-segment.js +4 -14
- package/dist/es/chart/mixins/accessibility-attributes-mixin.js +7 -7
- package/dist/es/chart/mixins/clip-animation-mixin.js +7 -7
- package/dist/es/chart/mixins/line-chart-mixin.js +27 -31
- package/dist/es/chart/mixins/note-mixin.js +3 -3
- package/dist/es/chart/mixins/pie-chart-mixin.js +9 -9
- package/dist/es/chart/mixins/plotarea-events-mixin.js +1 -1
- package/dist/es/chart/mixins/point-events-mixin.js +1 -1
- package/dist/es/chart/ohlc-chart/ohlc-chart.js +4 -14
- package/dist/es/chart/ohlc-chart/ohlc-point.js +15 -28
- package/dist/es/chart/pan-and-zoom/accept-key.js +3 -3
- package/dist/es/chart/pan-and-zoom/mousewheel-zoom.js +25 -33
- package/dist/es/chart/pan-and-zoom/pannable.js +29 -37
- package/dist/es/chart/pan-and-zoom/to-chart-axis-ranges.js +3 -3
- package/dist/es/chart/pan-and-zoom/zoom-selection.js +61 -70
- package/dist/es/chart/pane.js +71 -79
- package/dist/es/chart/pie-chart/pie-chart.js +153 -183
- package/dist/es/chart/pie-chart/pie-segment.js +82 -98
- package/dist/es/chart/plotarea/categorical-plotarea.js +285 -318
- package/dist/es/chart/plotarea/donut-plotarea.js +12 -22
- package/dist/es/chart/plotarea/funnel-plotarea.js +17 -27
- package/dist/es/chart/plotarea/heatmap-plotarea.js +139 -167
- package/dist/es/chart/plotarea/pie-plotarea.js +15 -25
- package/dist/es/chart/plotarea/plotarea-base.js +423 -462
- package/dist/es/chart/plotarea/plotarea-factory.js +15 -20
- package/dist/es/chart/plotarea/polar-plotarea-base.js +37 -51
- package/dist/es/chart/plotarea/polar-plotarea.js +39 -49
- package/dist/es/chart/plotarea/radar-plotarea.js +55 -65
- package/dist/es/chart/plotarea/xy-plotarea.js +111 -128
- package/dist/es/chart/polar-area-chart/polar-area-chart.js +22 -36
- package/dist/es/chart/polar-area-chart/polar-area-segment.js +7 -17
- package/dist/es/chart/polar-area-chart/spline-polar-area-segment.js +15 -25
- package/dist/es/chart/polar-line-chart/polar-line-chart.js +2 -11
- package/dist/es/chart/polar-scatter-chart/polar-scatter-chart.js +6 -16
- package/dist/es/chart/radar-area-chart/radar-area-chart.js +11 -21
- package/dist/es/chart/radar-area-chart/radar-area-segment.js +3 -13
- package/dist/es/chart/radar-area-chart/spline-radar-area-segment.js +3 -13
- package/dist/es/chart/radar-bar-chart/radar-bar-chart.js +19 -29
- package/dist/es/chart/radar-bar-chart/radar-segment.js +6 -12
- package/dist/es/chart/radar-line-chart/radar-line-chart.js +26 -35
- package/dist/es/chart/range-area-chart/range-area-chart.js +46 -58
- package/dist/es/chart/range-area-chart/range-area-point.js +55 -66
- package/dist/es/chart/range-area-chart/range-area-segment.js +19 -28
- package/dist/es/chart/range-area-chart/range-line-point.js +4 -14
- package/dist/es/chart/range-area-chart/spline-range-area-segment.js +11 -18
- package/dist/es/chart/range-area-chart/step-range-area-segment.js +7 -16
- package/dist/es/chart/range-bar-chart/range-bar-chart.js +18 -29
- package/dist/es/chart/range-bar-chart/range-bar.js +10 -23
- package/dist/es/chart/register-charts.js +20 -16
- package/dist/es/chart/scatter-charts/scatter-chart.js +100 -122
- package/dist/es/chart/scatter-charts/scatter-line-chart.js +15 -25
- package/dist/es/chart/selection.js +176 -201
- package/dist/es/chart/series-binder.js +55 -66
- package/dist/es/chart/theme/base-theme.js +75 -79
- package/dist/es/chart/theme/load-theme.js +52 -52
- package/dist/es/chart/tooltip/base-tooltip.js +17 -24
- package/dist/es/chart/tooltip/shared-tooltip.js +25 -31
- package/dist/es/chart/tooltip/tooltip.js +10 -20
- package/dist/es/chart/trendlines/calculate-moving-average.js +11 -13
- package/dist/es/chart/trendlines/calculate-polynomial.js +24 -26
- package/dist/es/chart/trendlines/calculate-slope.js +12 -14
- package/dist/es/chart/trendlines/check-all-positive.js +2 -5
- package/dist/es/chart/trendlines/exponential-trendline.js +15 -24
- package/dist/es/chart/trendlines/get-scatter-trendline-data.js +6 -7
- package/dist/es/chart/trendlines/get-trendline-data.js +6 -6
- package/dist/es/chart/trendlines/linear-trendline.js +12 -21
- package/dist/es/chart/trendlines/logarithmic-trendline.js +14 -23
- package/dist/es/chart/trendlines/moving-average.js +15 -26
- package/dist/es/chart/trendlines/polynomial-trendline.js +13 -21
- package/dist/es/chart/trendlines/power-trendline.js +15 -24
- package/dist/es/chart/trendlines/scatter-exponential-trendline.js +15 -24
- package/dist/es/chart/trendlines/scatter-linear-trendline.js +10 -16
- package/dist/es/chart/trendlines/scatter-logarithmic-trendline.js +17 -27
- package/dist/es/chart/trendlines/scatter-moving-average.js +7 -10
- package/dist/es/chart/trendlines/scatter-polynomial-trendline.js +11 -16
- package/dist/es/chart/trendlines/scatter-power-trendline.js +15 -22
- package/dist/es/chart/trendlines/scatter-trendline-registry.js +1 -1
- package/dist/es/chart/trendlines/scatter-value-getter.js +2 -5
- package/dist/es/chart/trendlines/trendline-factory.js +1 -1
- package/dist/es/chart/trendlines/trendline-registry.js +1 -1
- package/dist/es/chart/trendlines/x-value-limits.js +6 -8
- package/dist/es/chart/utils/any-has-z-index.js +1 -1
- package/dist/es/chart/utils/bind-segments.js +8 -8
- package/dist/es/chart/utils/categories-count.js +3 -3
- package/dist/es/chart/utils/count-numbers.js +4 -4
- package/dist/es/chart/utils/create-out-of-range-points.js +13 -22
- package/dist/es/chart/utils/eval-options.js +7 -10
- package/dist/es/chart/utils/filter-series-by-type.js +4 -4
- package/dist/es/chart/utils/get-field.js +1 -1
- package/dist/es/chart/utils/has-gradient-overlay.js +1 -1
- package/dist/es/chart/utils/is-date-axis.js +2 -2
- package/dist/es/chart/utils/parse-date-category.js +2 -2
- package/dist/es/chart/utils/segment-visible.js +2 -2
- package/dist/es/chart/waterfall-chart/waterfall-chart.js +41 -55
- package/dist/es/chart/waterfall-chart/waterfall-segment.js +16 -24
- package/dist/es/chart-wizard/get-wizard-data-from-data-rows.js +5 -6
- package/dist/es/chart-wizard/messages.js +1 -1
- package/dist/es/chart-wizard/state.js +145 -137
- package/dist/es/chart-wizard.js +12 -12
- package/dist/es/common/add-class.js +3 -3
- package/dist/es/common/align-path-to-pixel.js +2 -2
- package/dist/es/common/auto-text-color.js +1 -1
- package/dist/es/common/constants.js +53 -53
- package/dist/es/common/create-hash-set.js +59 -65
- package/dist/es/common/cycleDown.js +1 -1
- package/dist/es/common/deep-extend.js +10 -12
- package/dist/es/common/element-scale.js +9 -9
- package/dist/es/common/element-styles.js +8 -8
- package/dist/es/common/event-map.js +4 -4
- package/dist/es/common/event-utils.js +13 -13
- package/dist/es/common/find.js +2 -2
- package/dist/es/common/font-loader.js +42 -44
- package/dist/es/common/get-aria-template.js +2 -4
- package/dist/es/common/get-spacing.js +2 -4
- package/dist/es/common/get-supported-features.js +7 -7
- package/dist/es/common/get-template.js +2 -4
- package/dist/es/common/getter.js +5 -5
- package/dist/es/common/grep.js +3 -3
- package/dist/es/common/has-classes.js +2 -2
- package/dist/es/common/hash-map.js +11 -11
- package/dist/es/common/instance-observer.js +28 -33
- package/dist/es/common/keys.js +1 -1
- package/dist/es/common/map.js +4 -4
- package/dist/es/common/matrix.js +142 -150
- package/dist/es/common/mousewheel-delta.js +2 -2
- package/dist/es/common/observable.js +40 -52
- package/dist/es/common/remove-class.js +1 -1
- package/dist/es/common/render-icon.js +50 -60
- package/dist/es/common/set-default-options.js +1 -1
- package/dist/es/common/sparse-array-limits.js +4 -4
- package/dist/es/common/user-events.js +124 -150
- package/dist/es/core/axis-label.js +38 -43
- package/dist/es/core/axis.js +293 -345
- package/dist/es/core/box-element.js +36 -46
- package/dist/es/core/box.js +75 -83
- package/dist/es/core/category-axis.js +265 -314
- package/dist/es/core/chart-element.js +98 -109
- package/dist/es/core/constants.js +3 -3
- package/dist/es/core/curve-processor.js +86 -93
- package/dist/es/core/date-category-axis.js +381 -413
- package/dist/es/core/date-value-axis.js +108 -118
- package/dist/es/core/float-element.js +54 -78
- package/dist/es/core/gradients.js +3 -3
- package/dist/es/core/logarithmic-axis.js +134 -186
- package/dist/es/core/mixins/grid-lines-mixin.js +18 -20
- package/dist/es/core/mixins/radar-numeric-axis-mixin.js +46 -51
- package/dist/es/core/note.js +58 -73
- package/dist/es/core/numeric-axis.js +111 -133
- package/dist/es/core/pattern.js +4 -8
- package/dist/es/core/point.js +25 -34
- package/dist/es/core/polar-axis.js +73 -91
- package/dist/es/core/radar-category-axis.js +90 -114
- package/dist/es/core/radar-logarithmic-axis.js +10 -20
- package/dist/es/core/radar-numeric-axis.js +10 -20
- package/dist/es/core/ring.js +61 -68
- package/dist/es/core/root-element.js +40 -48
- package/dist/es/core/sector.js +11 -17
- package/dist/es/core/shape-builder.js +13 -23
- package/dist/es/core/shape-element.js +27 -37
- package/dist/es/core/text-box.js +50 -59
- package/dist/es/core/text.js +13 -24
- package/dist/es/core/title.js +19 -25
- package/dist/es/core/utils/auto-axis-max.js +3 -3
- package/dist/es/core/utils/auto-axis-min.js +3 -3
- package/dist/es/core/utils/auto-major-unit.js +4 -4
- package/dist/es/core/utils/box-diff.js +9 -9
- package/dist/es/core/utils/create-axis-grid-line.js +2 -4
- package/dist/es/core/utils/create-axis-tick.js +2 -4
- package/dist/es/core/utils/guid.js +3 -3
- package/dist/es/core/utils/rect-to-box.js +2 -2
- package/dist/es/date-utils/absolute-date-diff.js +2 -2
- package/dist/es/date-utils/add-duration.js +5 -5
- package/dist/es/date-utils/ceil-date.js +1 -1
- package/dist/es/date-utils/constants.js +17 -17
- package/dist/es/date-utils/date-index.js +3 -3
- package/dist/es/date-utils/duration.js +1 -1
- package/dist/es/date-utils/lte-date-index.js +4 -4
- package/dist/es/date-utils/parse-date.js +1 -1
- package/dist/es/date-utils/parse-dates.js +2 -2
- package/dist/es/date-utils/start-of-week.js +3 -5
- package/dist/es/date-utils/to-date.js +1 -1
- package/dist/es/date-utils/to-time.js +2 -2
- package/dist/es/drawing-utils.js +18 -17
- package/dist/es/gauges/arc/arc-gauge.js +29 -38
- package/dist/es/gauges/arc/arc-scale.js +16 -29
- package/dist/es/gauges/arc/range-pointer-animation.js +16 -25
- package/dist/es/gauges/arc/range-pointer.js +25 -46
- package/dist/es/gauges/circular/circular-gauge.js +7 -17
- package/dist/es/gauges/constants.js +14 -14
- package/dist/es/gauges/gauge.js +84 -96
- package/dist/es/gauges/linear/arrow-linear-pointer-animation.js +13 -25
- package/dist/es/gauges/linear/arrow-linear-pointer.js +23 -35
- package/dist/es/gauges/linear/bar-linear-pointer-animation.js +15 -24
- package/dist/es/gauges/linear/bar-linear-pointer.js +38 -51
- package/dist/es/gauges/linear/linear-gauge.js +61 -83
- package/dist/es/gauges/linear/linear-pointer.js +25 -39
- package/dist/es/gauges/linear/linear-scale.js +57 -74
- package/dist/es/gauges/pointer.js +11 -21
- package/dist/es/gauges/radial/radial-gauge.js +58 -81
- package/dist/es/gauges/radial/radial-pointer-animation.js +9 -15
- package/dist/es/gauges/radial/radial-pointer.js +33 -48
- package/dist/es/gauges/radial/radial-scale.js +154 -186
- package/dist/es/gauges/utils/build-label-element.js +10 -12
- package/dist/es/gauges/utils/get-range.js +2 -2
- package/dist/es/gauges/utils/pad.js +3 -3
- package/dist/es/gauges/utils/unpad.js +1 -1
- package/dist/es/map/attribution.js +42 -52
- package/dist/es/map/constants.js +5 -5
- package/dist/es/map/crs.js +68 -112
- package/dist/es/map/datums.js +3 -3
- package/dist/es/map/extent.js +40 -54
- package/dist/es/map/layers/bubble.js +52 -70
- package/dist/es/map/layers/layer.js +50 -56
- package/dist/es/map/layers/marker.js +109 -129
- package/dist/es/map/layers/shape.js +111 -133
- package/dist/es/map/layers/tile.js +144 -170
- package/dist/es/map/location.js +70 -78
- package/dist/es/map/map.js +261 -291
- package/dist/es/map/navigator.js +33 -39
- package/dist/es/map/scroller/draggable.js +98 -134
- package/dist/es/map/scroller/fx.js +39 -46
- package/dist/es/map/scroller/scroller.js +144 -174
- package/dist/es/map/tooltip/tooltip.js +15 -25
- package/dist/es/map/utils.js +25 -26
- package/dist/es/map/zoom.js +30 -36
- package/dist/es/qrcode/encodings/data-modes/alpha-numeric-data-mode.js +14 -26
- package/dist/es/qrcode/encodings/data-modes/byte-data-mode.js +15 -25
- package/dist/es/qrcode/encodings/data-modes/data-mode-instances.js +8 -7
- package/dist/es/qrcode/encodings/data-modes/numeric-data-mode.js +14 -24
- package/dist/es/qrcode/encodings/data-modes/qr-data-mode.js +15 -21
- package/dist/es/qrcode/encodings/encoders/iso-encoder.js +6 -16
- package/dist/es/qrcode/encodings/encoders/utf8-encoder.js +28 -36
- package/dist/es/qrcode/encodings/encoding-result.js +4 -10
- package/dist/es/qrcode/encodings/encoding.js +68 -192
- package/dist/es/qrcode/encodings/free-cell-visitor.js +16 -24
- package/dist/es/qrcode/encodings/utils/choose-mode.js +44 -0
- package/dist/es/qrcode/encodings/utils/get-data-codewords-count.js +13 -0
- package/dist/es/qrcode/encodings/utils/get-data-string.js +13 -0
- package/dist/es/qrcode/encodings/utils/get-modes.js +35 -0
- package/dist/es/qrcode/encodings/utils/get-version.js +23 -0
- package/dist/es/qrcode/encodings/utils/index.js +5 -0
- package/dist/es/qrcode/encodings/version-codewords.js +1 -1
- package/dist/es/qrcode/qrcode-validator.js +3 -5
- package/dist/es/qrcode/qrcode.js +104 -114
- package/dist/es/qrcode/utils.js +4 -4
- package/dist/es/sankey/calculation.js +286 -307
- package/dist/es/sankey/element.js +15 -23
- package/dist/es/sankey/label.js +29 -44
- package/dist/es/sankey/legend.js +15 -29
- package/dist/es/sankey/link.js +80 -98
- package/dist/es/sankey/node.js +26 -37
- package/dist/es/sankey/sankey.js +318 -385
- package/dist/es/sankey/title.js +9 -20
- package/dist/es/sankey/utils.js +18 -23
- package/dist/es/services/chart-service.js +24 -28
- package/dist/es/services/dom-events-builder.js +15 -15
- package/dist/es/services/format-service.js +30 -35
- package/dist/es/services/intl-service.js +14 -18
- package/dist/es/services/map-service.js +11 -11
- package/dist/es/services/template-service.js +9 -9
- package/dist/es/sparkline/shared-tooltip.js +11 -21
- package/dist/es/sparkline/sparkline.js +50 -60
- package/dist/es/stock/constants.js +3 -3
- package/dist/es/stock/fade-out-animation.js +12 -21
- package/dist/es/stock/navigator-hint.js +37 -49
- package/dist/es/stock/navigator.js +130 -161
- package/dist/es/stock/stock-chart.js +58 -67
- package/dist/es2015/chart/legend/legend-item.js +1 -1
- package/dist/es2015/qrcode/encodings/encoders/iso-encoder.js +1 -1
- package/dist/es2015/qrcode/encodings/encoders/utf8-encoder.js +1 -1
- package/dist/es2015/qrcode/encodings/encoding.js +3 -127
- package/dist/es2015/qrcode/encodings/utils/choose-mode.js +44 -0
- package/dist/es2015/qrcode/encodings/utils/get-data-codewords-count.js +13 -0
- package/dist/es2015/qrcode/encodings/utils/get-data-string.js +13 -0
- package/dist/es2015/qrcode/encodings/utils/get-modes.js +35 -0
- package/dist/es2015/qrcode/encodings/utils/get-version.js +23 -0
- package/dist/es2015/qrcode/encodings/utils/index.js +5 -0
- package/dist/npm/main.js +3222 -3589
- package/dist/systemjs/kendo-charts.js +1 -1
- package/package.json +19 -57
|
@@ -3,71 +3,65 @@ import { EncodingResult } from '../encoding-result';
|
|
|
3
3
|
import { DataModeInstances } from '../data-modes/data-mode-instances';
|
|
4
4
|
import { extend } from '../../utils';
|
|
5
5
|
import { toBitsString } from '../../utils';
|
|
6
|
-
import { getVersion } from '../
|
|
6
|
+
import { getVersion } from '../utils/index';
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
const BYTE = "byte";
|
|
9
9
|
|
|
10
|
-
export
|
|
11
|
-
|
|
12
|
-
|
|
10
|
+
export class Utf8Encoder extends Class {
|
|
11
|
+
constructor() {
|
|
12
|
+
super();
|
|
13
13
|
|
|
14
14
|
this.initProperties();
|
|
15
15
|
|
|
16
16
|
this.mode = DataModeInstances[this.encodingMode];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
|
|
20
|
-
Utf8Encoder.prototype = Object.create( Class && Class.prototype );
|
|
21
|
-
Utf8Encoder.prototype.constructor = Utf8Encoder;
|
|
22
|
-
|
|
23
|
-
Utf8Encoder.prototype.initProperties = function initProperties () {
|
|
19
|
+
initProperties() {
|
|
24
20
|
extend(this, {
|
|
25
21
|
encodingMode: BYTE,
|
|
26
22
|
utfBOM: "111011111011101110111111",
|
|
27
23
|
initialModeCountStringLength: 20,
|
|
28
24
|
ranges: [128, 2048, 65536, 2097152, 67108864]
|
|
29
25
|
});
|
|
30
|
-
}
|
|
26
|
+
}
|
|
31
27
|
|
|
32
|
-
|
|
33
|
-
|
|
28
|
+
getEncodingResult(inputString, errorCorrectionLevel) {
|
|
29
|
+
let data = this.encode(inputString),
|
|
34
30
|
dataCodewordsCount = this.getDataCodewordsCount(data),
|
|
35
31
|
version = getVersion(dataCodewordsCount, errorCorrectionLevel),
|
|
36
32
|
dataString = this.mode.getModeCountString(data.length / 8, version) + data;
|
|
37
33
|
|
|
38
34
|
return new EncodingResult(dataString, version);
|
|
39
|
-
}
|
|
35
|
+
}
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
|
|
37
|
+
getDataCodewordsCount(data) {
|
|
38
|
+
let dataLength = data.length,
|
|
43
39
|
dataCodewordsCount = Math.ceil((this.initialModeCountStringLength + dataLength) / 8);
|
|
44
40
|
|
|
45
41
|
return dataCodewordsCount;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
Utf8Encoder.prototype.encode = function encode (str) {
|
|
49
|
-
var this$1 = this;
|
|
42
|
+
}
|
|
50
43
|
|
|
51
|
-
|
|
44
|
+
encode(str) {
|
|
45
|
+
let result = this.utfBOM;
|
|
52
46
|
|
|
53
|
-
for (
|
|
54
|
-
result += this
|
|
47
|
+
for (let i = 0; i < str.length; i++) {
|
|
48
|
+
result += this.encodeCharacter(str.charCodeAt(i));
|
|
55
49
|
}
|
|
56
50
|
|
|
57
51
|
return result;
|
|
58
|
-
}
|
|
52
|
+
}
|
|
59
53
|
|
|
60
|
-
|
|
61
|
-
|
|
54
|
+
encodeCharacter(code) {
|
|
55
|
+
let bytesCount = this.getBytesCount(code),
|
|
62
56
|
bc = bytesCount - 1,
|
|
63
57
|
result = "";
|
|
64
58
|
|
|
65
59
|
if (bytesCount === 1) {
|
|
66
60
|
result = toBitsString(code, 8);
|
|
67
61
|
} else {
|
|
68
|
-
|
|
62
|
+
let significantOnes = 8 - bytesCount;
|
|
69
63
|
|
|
70
|
-
for (
|
|
64
|
+
for (let i = 0; i < bc; i++) {
|
|
71
65
|
result = toBitsString(code >> (i * 6) & 63 | 128, 8) + result;
|
|
72
66
|
}
|
|
73
67
|
|
|
@@ -75,17 +69,15 @@ export var Utf8Encoder = (function (Class) {
|
|
|
75
69
|
}
|
|
76
70
|
|
|
77
71
|
return result;
|
|
78
|
-
}
|
|
72
|
+
}
|
|
79
73
|
|
|
80
|
-
|
|
81
|
-
|
|
74
|
+
getBytesCount(code) {
|
|
75
|
+
let ranges = this.ranges;
|
|
82
76
|
|
|
83
|
-
for (
|
|
77
|
+
for (let i = 0; i < ranges.length; i++) {
|
|
84
78
|
if (code < ranges[i]) {
|
|
85
79
|
return i + 1;
|
|
86
80
|
}
|
|
87
81
|
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
return Utf8Encoder;
|
|
91
|
-
}(Class));
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import { Class } from '../../common';
|
|
2
2
|
|
|
3
|
-
export
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
export class EncodingResult extends Class {
|
|
4
|
+
constructor(dataString, version) {
|
|
5
|
+
super();
|
|
6
6
|
|
|
7
7
|
this.dataString = dataString;
|
|
8
8
|
this.version = version;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
if ( Class ) EncodingResult.__proto__ = Class;
|
|
12
|
-
EncodingResult.prototype = Object.create( Class && Class.prototype );
|
|
13
|
-
EncodingResult.prototype.constructor = EncodingResult;
|
|
14
|
-
|
|
15
|
-
return EncodingResult;
|
|
16
|
-
}(Class));
|
|
10
|
+
}
|
|
@@ -6,12 +6,8 @@ import { FreeCellVisitor } from './free-cell-visitor';
|
|
|
6
6
|
import { IsoEncoder } from './encoders/iso-encoder';
|
|
7
7
|
import { Utf8Encoder } from './encoders/utf8-encoder';
|
|
8
8
|
import { VersionsCodewordsInformation } from './version-codewords';
|
|
9
|
-
import { DataModeInstances } from './data-modes/data-mode-instances';
|
|
10
9
|
|
|
11
|
-
|
|
12
|
-
NUMERIC = "numeric",
|
|
13
|
-
ALPHA_NUMERIC = "alphanumeric",
|
|
14
|
-
BYTE = "byte",
|
|
10
|
+
let terminator = "0000",
|
|
15
11
|
powersOfTwo = { "1": 0 },
|
|
16
12
|
powersOfTwoResult = { "0": 1 },
|
|
17
13
|
irregularAlignmentPatternsStartDistance = {
|
|
@@ -30,57 +26,45 @@ var terminator = "0000",
|
|
|
30
26
|
/* eslint-disable arrow-body-style */
|
|
31
27
|
/* eslint-disable no-unused-vars */
|
|
32
28
|
maskPatternConditions = [
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
]
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
alphaExclusiveSet = "A-Z $%*+./:-",
|
|
47
|
-
alphaRegex = new RegExp("^[" + alphaExclusiveSet + "]+"),
|
|
48
|
-
alphaNumericRegex = new RegExp("^[" + alphaPattern + "]+"),
|
|
49
|
-
byteRegex = new RegExp("^[^" + alphaPattern + "]+"),
|
|
50
|
-
initMinNumericBeforeAlpha = 8,
|
|
51
|
-
initMinNumericBeforeByte = 5,
|
|
52
|
-
initMinAlphaBeforeByte = 8,
|
|
53
|
-
minNumericBeforeAlpha = 17,
|
|
54
|
-
minNumericBeforeByte = 9,
|
|
55
|
-
minAlphaBeforeByte = 16;
|
|
56
|
-
|
|
57
|
-
export var generatorPolynomials = [[1, 0], [1, 25, 0]];
|
|
29
|
+
(row, column) => { return (row + column) % 2 === 0; },
|
|
30
|
+
(row, column) => { return row % 2 === 0; },
|
|
31
|
+
(row, column) => { return column % 3 === 0; },
|
|
32
|
+
(row, column) => { return (row + column) % 3 === 0; },
|
|
33
|
+
(row, column) => { return (Math.floor(row / 2) + Math.floor(column / 3)) % 2 === 0; },
|
|
34
|
+
(row, column) => { return ((row * column) % 2) + ((row * column) % 3) === 0; },
|
|
35
|
+
(row, column) => { return (((row * column) % 2) + ((row * column) % 3)) % 2 === 0; },
|
|
36
|
+
(row, column) => { return (((row + column) % 2) + ((row * column) % 3)) % 2 === 0; }
|
|
37
|
+
];
|
|
38
|
+
/* eslint-enable no-unused-vars */
|
|
39
|
+
/* eslint-enable arrow-body-style */
|
|
40
|
+
|
|
41
|
+
export const generatorPolynomials = [[1, 0], [1, 25, 0]];
|
|
58
42
|
|
|
59
43
|
export function fillFunctionCell(matrices, bit, x, y) {
|
|
60
|
-
for (
|
|
44
|
+
for (let i = 0; i < matrices.length; i++) {
|
|
61
45
|
matrices[i][x][y] = bit;
|
|
62
46
|
}
|
|
63
47
|
}
|
|
64
48
|
|
|
65
49
|
export function fillDataCell(matrices, bit, x, y) {
|
|
66
|
-
for (
|
|
50
|
+
for (let i = 0; i < maskPatternConditions.length; i++) {
|
|
67
51
|
matrices[i][x][y] = maskPatternConditions[i](x, y) ? bit ^ 1 : parseInt(bit, 10);
|
|
68
52
|
}
|
|
69
53
|
}
|
|
70
54
|
|
|
71
55
|
export function fillData(matrices, blocks) {
|
|
72
|
-
|
|
56
|
+
let cellVisitor = new FreeCellVisitor(matrices[0]),
|
|
73
57
|
block,
|
|
74
58
|
codewordIdx,
|
|
75
59
|
cell;
|
|
76
60
|
|
|
77
|
-
for (
|
|
61
|
+
for (let blockIdx = 0; blockIdx < blocks.length; blockIdx++) {
|
|
78
62
|
block = blocks[blockIdx];
|
|
79
63
|
codewordIdx = 0;
|
|
80
64
|
|
|
81
65
|
while (block.length > 0) {
|
|
82
|
-
for (
|
|
83
|
-
for (
|
|
66
|
+
for (let i = 0; i < block.length; i++) {
|
|
67
|
+
for (let j = 0; j < 8; j++) {
|
|
84
68
|
cell = cellVisitor.getNextCell();
|
|
85
69
|
fillDataCell(matrices, block[i][codewordIdx].charAt(j), cell.row, cell.column);
|
|
86
70
|
}
|
|
@@ -100,10 +84,10 @@ export function fillData(matrices, blocks) {
|
|
|
100
84
|
}
|
|
101
85
|
|
|
102
86
|
export function padDataString(initialDataString, totalDataCodewords) {
|
|
103
|
-
|
|
87
|
+
let dataBitsCount = totalDataCodewords * 8,
|
|
104
88
|
terminatorIndex = 0,
|
|
105
89
|
paddingCodewordIndex = 0;
|
|
106
|
-
|
|
90
|
+
let dataString = initialDataString;
|
|
107
91
|
|
|
108
92
|
while (dataString.length < dataBitsCount && terminatorIndex < terminator.length) {
|
|
109
93
|
dataString += terminator.charAt(terminatorIndex++);
|
|
@@ -122,8 +106,8 @@ export function padDataString(initialDataString, totalDataCodewords) {
|
|
|
122
106
|
}
|
|
123
107
|
|
|
124
108
|
export function generatePowersOfTwo() {
|
|
125
|
-
|
|
126
|
-
|
|
109
|
+
let result;
|
|
110
|
+
let power;
|
|
127
111
|
|
|
128
112
|
for (power = 1; power < 255; power++) {
|
|
129
113
|
result = powersOfTwoResult[power - 1] * 2;
|
|
@@ -141,10 +125,10 @@ export function generatePowersOfTwo() {
|
|
|
141
125
|
}
|
|
142
126
|
|
|
143
127
|
export function xorPolynomials(x, y) {
|
|
144
|
-
|
|
128
|
+
let result = [],
|
|
145
129
|
idx = x.length - 2;
|
|
146
130
|
|
|
147
|
-
for (
|
|
131
|
+
for (let i = idx; i >= 0; i--) {
|
|
148
132
|
result[i] = x[i] ^ y[i];
|
|
149
133
|
}
|
|
150
134
|
|
|
@@ -152,10 +136,10 @@ export function xorPolynomials(x, y) {
|
|
|
152
136
|
}
|
|
153
137
|
|
|
154
138
|
export function multiplyPolynomials(x, y) {
|
|
155
|
-
|
|
139
|
+
let result = [];
|
|
156
140
|
|
|
157
|
-
for (
|
|
158
|
-
for (
|
|
141
|
+
for (let i = 0; i < x.length; i++) {
|
|
142
|
+
for (let j = 0; j < y.length; j++) {
|
|
159
143
|
if (result[i + j] === undefined) {
|
|
160
144
|
result[i + j] = (x[i] + (y[j] >= 0 ? y[j] : 0)) % 255;
|
|
161
145
|
} else {
|
|
@@ -168,10 +152,10 @@ export function multiplyPolynomials(x, y) {
|
|
|
168
152
|
}
|
|
169
153
|
|
|
170
154
|
export function generateGeneratorPolynomials() {
|
|
171
|
-
|
|
155
|
+
let maxErrorCorrectionCodeWordsCount = 68;
|
|
172
156
|
|
|
173
|
-
for (
|
|
174
|
-
|
|
157
|
+
for (let idx = 2; idx <= maxErrorCorrectionCodeWordsCount; idx++) {
|
|
158
|
+
let firstPolynomial = generatorPolynomials[idx - 1],
|
|
175
159
|
secondPolynomial = [idx, 0];
|
|
176
160
|
|
|
177
161
|
generatorPolynomials[idx] = multiplyPolynomials(firstPolynomial, secondPolynomial);
|
|
@@ -183,7 +167,7 @@ generatePowersOfTwo();
|
|
|
183
167
|
generateGeneratorPolynomials();
|
|
184
168
|
|
|
185
169
|
export function multiplyByConstant(polynomial, power) {
|
|
186
|
-
|
|
170
|
+
let result = [],
|
|
187
171
|
idx = polynomial.length - 1;
|
|
188
172
|
|
|
189
173
|
do {
|
|
@@ -196,7 +180,7 @@ export function multiplyByConstant(polynomial, power) {
|
|
|
196
180
|
}
|
|
197
181
|
|
|
198
182
|
export function generateErrorCodewords(data, errorCodewordsCount) {
|
|
199
|
-
|
|
183
|
+
let generator = generatorPolynomials[errorCodewordsCount - 1],
|
|
200
184
|
result = new Array(errorCodewordsCount).concat(data),
|
|
201
185
|
generatorPolynomial = new Array(result.length - generator.length).concat(generator),
|
|
202
186
|
steps = data.length,
|
|
@@ -219,7 +203,7 @@ export function generateErrorCodewords(data, errorCodewordsCount) {
|
|
|
219
203
|
}
|
|
220
204
|
|
|
221
205
|
export function getBlocks(dataStream, versionCodewordsInformation) {
|
|
222
|
-
|
|
206
|
+
let codewordStart = 0,
|
|
223
207
|
dataBlocks = [],
|
|
224
208
|
errorBlocks = [],
|
|
225
209
|
dataBlock,
|
|
@@ -229,15 +213,15 @@ export function getBlocks(dataStream, versionCodewordsInformation) {
|
|
|
229
213
|
messagePolynomial,
|
|
230
214
|
codeword;
|
|
231
215
|
|
|
232
|
-
for (
|
|
216
|
+
for (let groupIdx = 0; groupIdx < versionGroups.length; groupIdx++) {
|
|
233
217
|
groupBlocksCount = versionGroups[groupIdx][0];
|
|
234
218
|
|
|
235
|
-
for (
|
|
219
|
+
for (let blockIdx = 0; blockIdx < groupBlocksCount; blockIdx++) {
|
|
236
220
|
blockCodewordsCount = versionGroups[groupIdx][1];
|
|
237
221
|
dataBlock = [];
|
|
238
222
|
messagePolynomial = [];
|
|
239
223
|
|
|
240
|
-
for (
|
|
224
|
+
for (let codewordIdx = 1; codewordIdx <= blockCodewordsCount; codewordIdx++) {
|
|
241
225
|
codeword = dataStream.substring(codewordStart, codewordStart + 8);
|
|
242
226
|
dataBlock.push(codeword);
|
|
243
227
|
messagePolynomial[blockCodewordsCount - codewordIdx] = toDecimal(codeword);
|
|
@@ -252,117 +236,9 @@ export function getBlocks(dataStream, versionCodewordsInformation) {
|
|
|
252
236
|
return [dataBlocks, errorBlocks];
|
|
253
237
|
}
|
|
254
238
|
|
|
255
|
-
export function chooseMode(str, minNumericBeforeAlpha, minNumericBeforeByte, minAlphaBeforeByte, previousMode) {
|
|
256
|
-
var numeric = numberRegex.exec(str),
|
|
257
|
-
numericMatch = numeric ? numeric[0] : "",
|
|
258
|
-
alpha = alphaRegex.exec(str),
|
|
259
|
-
alphaMatch = alpha ? alpha[0] : "",
|
|
260
|
-
alphaNumeric = alphaNumericRegex.exec(str),
|
|
261
|
-
alphaNumericMatch = alphaNumeric ? alphaNumeric[0] : "",
|
|
262
|
-
mode,
|
|
263
|
-
modeString;
|
|
264
|
-
|
|
265
|
-
if (numericMatch &&
|
|
266
|
-
(numericMatch.length >= minNumericBeforeAlpha || str.length === numericMatch.length ||
|
|
267
|
-
(numericMatch.length >= minNumericBeforeByte && !alphaNumericRegex.test(str.charAt(numericMatch.length))))) {
|
|
268
|
-
mode = NUMERIC;
|
|
269
|
-
modeString = numericMatch;
|
|
270
|
-
} else if (alphaNumericMatch && (str.length === alphaNumericMatch.length ||
|
|
271
|
-
alphaNumericMatch.length >= minAlphaBeforeByte || previousMode === ALPHA_NUMERIC)) {
|
|
272
|
-
mode = ALPHA_NUMERIC;
|
|
273
|
-
modeString = numericMatch || alphaMatch;
|
|
274
|
-
} else {
|
|
275
|
-
mode = BYTE;
|
|
276
|
-
|
|
277
|
-
if (alphaNumericMatch) {
|
|
278
|
-
modeString = alphaNumericMatch + byteRegex.exec(str.substring(alphaNumericMatch.length))[0];
|
|
279
|
-
} else {
|
|
280
|
-
modeString = byteRegex.exec(str)[0];
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
return {
|
|
285
|
-
mode: mode,
|
|
286
|
-
modeString: modeString
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
export function getModes(inputString) {
|
|
291
|
-
var modes = [],
|
|
292
|
-
previousMode,
|
|
293
|
-
idx = 0;
|
|
294
|
-
var str = inputString;
|
|
295
|
-
|
|
296
|
-
modes.push(chooseMode(str, initMinNumericBeforeAlpha, initMinNumericBeforeByte, initMinAlphaBeforeByte, previousMode));
|
|
297
|
-
previousMode = modes[0].mode;
|
|
298
|
-
str = str.substr(modes[0].modeString.length);
|
|
299
|
-
|
|
300
|
-
while (str.length > 0) {
|
|
301
|
-
var nextMode = chooseMode(str, minNumericBeforeAlpha, minNumericBeforeByte, minAlphaBeforeByte, previousMode);
|
|
302
|
-
|
|
303
|
-
if (nextMode.mode !== previousMode) {
|
|
304
|
-
previousMode = nextMode.mode;
|
|
305
|
-
modes.push(nextMode);
|
|
306
|
-
idx++;
|
|
307
|
-
} else {
|
|
308
|
-
modes[idx].modeString += nextMode.modeString;
|
|
309
|
-
}
|
|
310
|
-
|
|
311
|
-
str = str.substr(nextMode.modeString.length);
|
|
312
|
-
}
|
|
313
|
-
|
|
314
|
-
return modes;
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
export function getDataCodewordsCount(modes) {
|
|
318
|
-
var length = 0,
|
|
319
|
-
mode;
|
|
320
|
-
|
|
321
|
-
for (var i = 0; i < modes.length; i++) {
|
|
322
|
-
mode = DataModeInstances[modes[i].mode];
|
|
323
|
-
length += mode.getStringBitsLength(modes[i].modeString.length);
|
|
324
|
-
}
|
|
325
|
-
|
|
326
|
-
return Math.ceil(length / 8);
|
|
327
|
-
}
|
|
328
|
-
|
|
329
|
-
export function getVersion(dataCodewordsCount, errorCorrectionLevel) {
|
|
330
|
-
var x = 0,
|
|
331
|
-
y = VersionsCodewordsInformation.length - 1,
|
|
332
|
-
version = Math.floor(VersionsCodewordsInformation.length / 2);
|
|
333
|
-
|
|
334
|
-
do {
|
|
335
|
-
if (dataCodewordsCount < VersionsCodewordsInformation[version][errorCorrectionLevel].totalDataCodewords) {
|
|
336
|
-
y = version;
|
|
337
|
-
} else {
|
|
338
|
-
x = version;
|
|
339
|
-
}
|
|
340
|
-
|
|
341
|
-
version = x + Math.floor((y - x) / 2);
|
|
342
|
-
} while (y - x > 1);
|
|
343
|
-
|
|
344
|
-
if (dataCodewordsCount <= VersionsCodewordsInformation[x][errorCorrectionLevel].totalDataCodewords) {
|
|
345
|
-
return version + 1;
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
return y + 1;
|
|
349
|
-
}
|
|
350
|
-
|
|
351
|
-
export function getDataString(modes, version) {
|
|
352
|
-
var dataString = "",
|
|
353
|
-
mode;
|
|
354
|
-
|
|
355
|
-
for (var i = 0; i < modes.length; i++) {
|
|
356
|
-
mode = DataModeInstances[modes[i].mode];
|
|
357
|
-
dataString += mode.encode(modes[i].modeString, version);
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
return dataString;
|
|
361
|
-
}
|
|
362
|
-
|
|
363
239
|
//fix case all zeros
|
|
364
240
|
export function encodeFormatInformation(format) {
|
|
365
|
-
|
|
241
|
+
let formatNumber = toDecimal(format),
|
|
366
242
|
encodedString,
|
|
367
243
|
result = "";
|
|
368
244
|
|
|
@@ -372,7 +248,7 @@ export function encodeFormatInformation(format) {
|
|
|
372
248
|
|
|
373
249
|
encodedString = encodeBCH(toDecimal(format), formatGeneratorPolynomial, 15);
|
|
374
250
|
|
|
375
|
-
for (
|
|
251
|
+
for (let i = 0; i < encodedString.length; i++) {
|
|
376
252
|
result += encodedString.charAt(i) ^ formatMaskPattern.charAt(i);
|
|
377
253
|
}
|
|
378
254
|
|
|
@@ -380,7 +256,7 @@ export function encodeFormatInformation(format) {
|
|
|
380
256
|
}
|
|
381
257
|
|
|
382
258
|
export function encodeBCH(value, generatorPolynomial, codeLength) {
|
|
383
|
-
|
|
259
|
+
let generatorNumber = toDecimal(generatorPolynomial),
|
|
384
260
|
polynomialLength = generatorPolynomial.length - 1,
|
|
385
261
|
valueNumber = value << polynomialLength,
|
|
386
262
|
length = codeLength - polynomialLength,
|
|
@@ -393,9 +269,9 @@ export function encodeBCH(value, generatorPolynomial, codeLength) {
|
|
|
393
269
|
}
|
|
394
270
|
|
|
395
271
|
export function dividePolynomials(numberX, numberY) {
|
|
396
|
-
|
|
272
|
+
let yLength = numberY.toString(2).length,
|
|
397
273
|
xLength = numberX.toString(2).length;
|
|
398
|
-
|
|
274
|
+
let x = numberX;
|
|
399
275
|
|
|
400
276
|
do {
|
|
401
277
|
x ^= numberY << xLength - yLength;
|
|
@@ -411,13 +287,13 @@ export function getNumberAt(str, idx) {
|
|
|
411
287
|
}
|
|
412
288
|
|
|
413
289
|
export function initMatrices(version) {
|
|
414
|
-
|
|
290
|
+
let matrices = [],
|
|
415
291
|
modules = 17 + 4 * version;
|
|
416
292
|
|
|
417
|
-
for (
|
|
293
|
+
for (let i = 0; i < maskPatternConditions.length; i++) {
|
|
418
294
|
matrices[i] = new Array(modules);
|
|
419
295
|
|
|
420
|
-
for (
|
|
296
|
+
for (let j = 0; j < modules; j++) {
|
|
421
297
|
matrices[i][j] = new Array(modules);
|
|
422
298
|
}
|
|
423
299
|
}
|
|
@@ -426,7 +302,7 @@ export function initMatrices(version) {
|
|
|
426
302
|
}
|
|
427
303
|
|
|
428
304
|
export function addFormatInformation(matrices, formatString) {
|
|
429
|
-
|
|
305
|
+
let matrix = matrices[0],
|
|
430
306
|
x,
|
|
431
307
|
y,
|
|
432
308
|
idx = 0,
|
|
@@ -462,7 +338,7 @@ export function encodeVersionInformation(version) {
|
|
|
462
338
|
}
|
|
463
339
|
|
|
464
340
|
export function addVersionInformation(matrices, dataString) {
|
|
465
|
-
|
|
341
|
+
let matrix = matrices[0],
|
|
466
342
|
modules = matrix.length,
|
|
467
343
|
x1 = 0,
|
|
468
344
|
y1 = modules - 11,
|
|
@@ -472,7 +348,7 @@ export function addVersionInformation(matrices, dataString) {
|
|
|
472
348
|
mod,
|
|
473
349
|
value;
|
|
474
350
|
|
|
475
|
-
for (
|
|
351
|
+
for (let idx = 0; idx < dataString.length; idx++) {
|
|
476
352
|
quotient = Math.floor(idx / 3);
|
|
477
353
|
mod = idx % 3;
|
|
478
354
|
value = getNumberAt(dataString, dataString.length - idx - 1);
|
|
@@ -483,12 +359,12 @@ export function addVersionInformation(matrices, dataString) {
|
|
|
483
359
|
}
|
|
484
360
|
|
|
485
361
|
export function addCentricPattern(matrices, pattern, x, y) {
|
|
486
|
-
|
|
362
|
+
let size = pattern.length + 2,
|
|
487
363
|
length = pattern.length + 1,
|
|
488
364
|
value;
|
|
489
365
|
|
|
490
|
-
for (
|
|
491
|
-
for (
|
|
366
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
367
|
+
for (let j = i; j < size - i; j++) {
|
|
492
368
|
value = pattern[i];
|
|
493
369
|
|
|
494
370
|
fillFunctionCell(matrices, value, x + j, y + i);
|
|
@@ -500,7 +376,7 @@ export function addCentricPattern(matrices, pattern, x, y) {
|
|
|
500
376
|
}
|
|
501
377
|
|
|
502
378
|
export function addFinderSeparator(matrices, direction, x, y) {
|
|
503
|
-
|
|
379
|
+
let nextX = x,
|
|
504
380
|
nextY = y,
|
|
505
381
|
matrix = matrices[0];
|
|
506
382
|
|
|
@@ -514,7 +390,7 @@ export function addFinderSeparator(matrices, direction, x, y) {
|
|
|
514
390
|
}
|
|
515
391
|
|
|
516
392
|
export function addFinderPatterns(matrices) {
|
|
517
|
-
|
|
393
|
+
let modules = matrices[0].length;
|
|
518
394
|
|
|
519
395
|
addCentricPattern(matrices, finderPattern, 0, 0);
|
|
520
396
|
addFinderSeparator(matrices, [-1, -1], 7, 7);
|
|
@@ -529,7 +405,7 @@ export function addAlignmentPatterns(matrices, version) {
|
|
|
529
405
|
return;
|
|
530
406
|
}
|
|
531
407
|
|
|
532
|
-
|
|
408
|
+
let matrix = matrices[0],
|
|
533
409
|
modules = matrix.length,
|
|
534
410
|
pointsCount = Math.floor(version / 7),
|
|
535
411
|
points = [6],
|
|
@@ -549,8 +425,8 @@ export function addAlignmentPatterns(matrices, version) {
|
|
|
549
425
|
points.push(points[idx++] + distance);
|
|
550
426
|
}
|
|
551
427
|
|
|
552
|
-
for (
|
|
553
|
-
for (
|
|
428
|
+
for (let i = 0; i < points.length; i++) {
|
|
429
|
+
for (let j = 0; j < points.length; j++) {
|
|
554
430
|
if (matrix[points[i]][points[j]] === undefined) {
|
|
555
431
|
addCentricPattern(matrices, alignmentPattern, points[i] - 2, points[j] - 2);
|
|
556
432
|
}
|
|
@@ -559,12 +435,12 @@ export function addAlignmentPatterns(matrices, version) {
|
|
|
559
435
|
}
|
|
560
436
|
|
|
561
437
|
export function addTimingFunctions(matrices) {
|
|
562
|
-
|
|
438
|
+
let row = 6,
|
|
563
439
|
column = 6,
|
|
564
440
|
value = 1,
|
|
565
441
|
modules = matrices[0].length;
|
|
566
442
|
|
|
567
|
-
for (
|
|
443
|
+
for (let i = 8; i < modules - 8; i++) {
|
|
568
444
|
fillFunctionCell(matrices, value, row, i);
|
|
569
445
|
fillFunctionCell(matrices, value, i, column);
|
|
570
446
|
value ^= 1;
|
|
@@ -572,7 +448,7 @@ export function addTimingFunctions(matrices) {
|
|
|
572
448
|
}
|
|
573
449
|
|
|
574
450
|
export function scoreMaskMatrixes(matrices) {
|
|
575
|
-
|
|
451
|
+
let scores = [],
|
|
576
452
|
previousBits = [],
|
|
577
453
|
darkModules = [],
|
|
578
454
|
patterns = [],
|
|
@@ -591,9 +467,9 @@ export function scoreMaskMatrixes(matrices) {
|
|
|
591
467
|
previousBits[i] = [];
|
|
592
468
|
}
|
|
593
469
|
|
|
594
|
-
for (
|
|
595
|
-
for (
|
|
596
|
-
for (
|
|
470
|
+
for (let rowIndex = 0; rowIndex < modulesLength; rowIndex++) {
|
|
471
|
+
for (let columnIndex = 0; columnIndex < modulesLength; columnIndex++) {
|
|
472
|
+
for (let matrixIndex = 0; matrixIndex < matrices.length; matrixIndex++) {
|
|
597
473
|
matrix = matrices[matrixIndex];
|
|
598
474
|
darkModules[matrixIndex] += parseInt(matrix[rowIndex][columnIndex], 10);
|
|
599
475
|
|
|
@@ -613,7 +489,7 @@ export function scoreMaskMatrixes(matrices) {
|
|
|
613
489
|
}
|
|
614
490
|
}
|
|
615
491
|
|
|
616
|
-
|
|
492
|
+
let total = modulesLength * modulesLength,
|
|
617
493
|
minIdx,
|
|
618
494
|
min = Number.MAX_VALUE;
|
|
619
495
|
|
|
@@ -652,7 +528,7 @@ export function scoreAdjacentSameBits(idx, scores, previousBits, bit, adjacentBi
|
|
|
652
528
|
}
|
|
653
529
|
|
|
654
530
|
export function calculateDarkModulesRatioScore(darkModules, total) {
|
|
655
|
-
|
|
531
|
+
let percent = Math.floor((darkModules / total) * 100),
|
|
656
532
|
mod5 = percent % 5,
|
|
657
533
|
previous = Math.abs(percent - mod5 - 50),
|
|
658
534
|
next = Math.abs(percent + 5 - mod5 - 50),
|
|
@@ -670,7 +546,7 @@ export function createQRCodeDataEncoder(encoding) {
|
|
|
670
546
|
}
|
|
671
547
|
|
|
672
548
|
export function encodeData(inputString, errorCorrectionLevel, encoding) {
|
|
673
|
-
|
|
549
|
+
let encoder = createQRCodeDataEncoder(encoding),
|
|
674
550
|
encodingResult = encoder.getEncodingResult(inputString, errorCorrectionLevel),
|
|
675
551
|
version = encodingResult.version,
|
|
676
552
|
versionInformation = VersionsCodewordsInformation[version - 1][errorCorrectionLevel],
|
|
@@ -689,14 +565,14 @@ export function encodeData(inputString, errorCorrectionLevel, encoding) {
|
|
|
689
565
|
addFormatInformation(matrices, toBitsString(0, 15));
|
|
690
566
|
fillData(matrices, blocks);
|
|
691
567
|
|
|
692
|
-
|
|
568
|
+
let minIdx = scoreMaskMatrixes(matrices),
|
|
693
569
|
optimalMatrix = matrices[minIdx];
|
|
694
570
|
|
|
695
571
|
if (version >= 7) {
|
|
696
572
|
addVersionInformation([optimalMatrix], encodeVersionInformation(version));
|
|
697
573
|
}
|
|
698
574
|
|
|
699
|
-
|
|
575
|
+
let formatString = errorCorrectionPatterns[errorCorrectionLevel] + toBitsString(minIdx, 3);
|
|
700
576
|
addFormatInformation([optimalMatrix], encodeFormatInformation(formatString));
|
|
701
577
|
|
|
702
578
|
return optimalMatrix;
|