@wecom/wecom-openclaw-cli 1.0.15 → 1.0.17
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/_virtual/_commonjsHelpers.js +8 -0
- package/dist/_virtual/_commonjsHelpers.js.map +1 -0
- package/dist/_virtual/alignment-pattern.js +6 -0
- package/dist/_virtual/alignment-pattern.js.map +1 -0
- package/dist/_virtual/bitmapper.js +6 -0
- package/dist/_virtual/bitmapper.js.map +1 -0
- package/dist/_virtual/browser.js +6 -0
- package/dist/_virtual/browser.js.map +1 -0
- package/dist/_virtual/canvas.js +6 -0
- package/dist/_virtual/canvas.js.map +1 -0
- package/dist/_virtual/chunkstream.js +6 -0
- package/dist/_virtual/chunkstream.js.map +1 -0
- package/dist/_virtual/crc.js +6 -0
- package/dist/_virtual/crc.js.map +1 -0
- package/dist/_virtual/dijkstra.js +6 -0
- package/dist/_virtual/dijkstra.js.map +1 -0
- package/dist/_virtual/error-correction-code.js +6 -0
- package/dist/_virtual/error-correction-code.js.map +1 -0
- package/dist/_virtual/error-correction-level.js +6 -0
- package/dist/_virtual/error-correction-level.js.map +1 -0
- package/dist/_virtual/filter-parse-async.js +6 -0
- package/dist/_virtual/filter-parse-async.js.map +1 -0
- package/dist/_virtual/filter-parse-sync.js +6 -0
- package/dist/_virtual/filter-parse-sync.js.map +1 -0
- package/dist/_virtual/filter-parse.js +6 -0
- package/dist/_virtual/filter-parse.js.map +1 -0
- package/dist/_virtual/finder-pattern.js +6 -0
- package/dist/_virtual/finder-pattern.js.map +1 -0
- package/dist/_virtual/format-info.js +6 -0
- package/dist/_virtual/format-info.js.map +1 -0
- package/dist/_virtual/galois-field.js +6 -0
- package/dist/_virtual/galois-field.js.map +1 -0
- package/dist/_virtual/index.js +10 -0
- package/dist/_virtual/index.js.map +1 -0
- package/dist/_virtual/interlace.js +6 -0
- package/dist/_virtual/interlace.js.map +1 -0
- package/dist/_virtual/mask-pattern.js +6 -0
- package/dist/_virtual/mask-pattern.js.map +1 -0
- package/dist/_virtual/mode.js +6 -0
- package/dist/_virtual/mode.js.map +1 -0
- package/dist/_virtual/packer-async.js +6 -0
- package/dist/_virtual/packer-async.js.map +1 -0
- package/dist/_virtual/packer.js +6 -0
- package/dist/_virtual/packer.js.map +1 -0
- package/dist/_virtual/parser-async.js +6 -0
- package/dist/_virtual/parser-async.js.map +1 -0
- package/dist/_virtual/parser.js +6 -0
- package/dist/_virtual/parser.js.map +1 -0
- package/dist/_virtual/png-sync.js +6 -0
- package/dist/_virtual/png-sync.js.map +1 -0
- package/dist/_virtual/png.js +6 -0
- package/dist/_virtual/png.js.map +1 -0
- package/dist/_virtual/png2.js +6 -0
- package/dist/_virtual/png2.js.map +1 -0
- package/dist/_virtual/polynomial.js +6 -0
- package/dist/_virtual/polynomial.js.map +1 -0
- package/dist/_virtual/qrcode.js +6 -0
- package/dist/_virtual/qrcode.js.map +1 -0
- package/dist/_virtual/regex.js +6 -0
- package/dist/_virtual/regex.js.map +1 -0
- package/dist/_virtual/segments.js +6 -0
- package/dist/_virtual/segments.js.map +1 -0
- package/dist/_virtual/server.js +6 -0
- package/dist/_virtual/server.js.map +1 -0
- package/dist/_virtual/svg-tag.js +6 -0
- package/dist/_virtual/svg-tag.js.map +1 -0
- package/dist/_virtual/svg.js +6 -0
- package/dist/_virtual/svg.js.map +1 -0
- package/dist/_virtual/sync-inflate.js +6 -0
- package/dist/_virtual/sync-inflate.js.map +1 -0
- package/dist/_virtual/sync-reader.js +6 -0
- package/dist/_virtual/sync-reader.js.map +1 -0
- package/dist/_virtual/terminal-small.js +6 -0
- package/dist/_virtual/terminal-small.js.map +1 -0
- package/dist/_virtual/terminal.js +6 -0
- package/dist/_virtual/terminal.js.map +1 -0
- package/dist/_virtual/terminal2.js +6 -0
- package/dist/_virtual/terminal2.js.map +1 -0
- package/dist/_virtual/utf8.js +6 -0
- package/dist/_virtual/utf8.js.map +1 -0
- package/dist/_virtual/utils.js +6 -0
- package/dist/_virtual/utils.js.map +1 -0
- package/dist/_virtual/utils2.js +6 -0
- package/dist/_virtual/utils2.js.map +1 -0
- package/dist/_virtual/version-check.js +6 -0
- package/dist/_virtual/version-check.js.map +1 -0
- package/dist/_virtual/version.js +6 -0
- package/dist/_virtual/version.js.map +1 -0
- package/dist/node_modules/dijkstrajs/dijkstra.js +179 -0
- package/dist/node_modules/dijkstrajs/dijkstra.js.map +1 -0
- package/dist/node_modules/pngjs/lib/bitmapper.js +281 -0
- package/dist/node_modules/pngjs/lib/bitmapper.js.map +1 -0
- package/dist/node_modules/pngjs/lib/bitpacker.js +172 -0
- package/dist/node_modules/pngjs/lib/bitpacker.js.map +1 -0
- package/dist/node_modules/pngjs/lib/chunkstream.js +204 -0
- package/dist/node_modules/pngjs/lib/chunkstream.js.map +1 -0
- package/dist/node_modules/pngjs/lib/constants.js +44 -0
- package/dist/node_modules/pngjs/lib/constants.js.map +1 -0
- package/dist/node_modules/pngjs/lib/crc.js +53 -0
- package/dist/node_modules/pngjs/lib/crc.js.map +1 -0
- package/dist/node_modules/pngjs/lib/filter-pack.js +185 -0
- package/dist/node_modules/pngjs/lib/filter-pack.js.map +1 -0
- package/dist/node_modules/pngjs/lib/filter-parse-async.js +40 -0
- package/dist/node_modules/pngjs/lib/filter-parse-async.js.map +1 -0
- package/dist/node_modules/pngjs/lib/filter-parse-sync.js +36 -0
- package/dist/node_modules/pngjs/lib/filter-parse-sync.js.map +1 -0
- package/dist/node_modules/pngjs/lib/filter-parse.js +192 -0
- package/dist/node_modules/pngjs/lib/filter-parse.js.map +1 -0
- package/dist/node_modules/pngjs/lib/format-normaliser.js +105 -0
- package/dist/node_modules/pngjs/lib/format-normaliser.js.map +1 -0
- package/dist/node_modules/pngjs/lib/interlace.js +108 -0
- package/dist/node_modules/pngjs/lib/interlace.js.map +1 -0
- package/dist/node_modules/pngjs/lib/packer-async.js +67 -0
- package/dist/node_modules/pngjs/lib/packer-async.js.map +1 -0
- package/dist/node_modules/pngjs/lib/packer-sync.js +72 -0
- package/dist/node_modules/pngjs/lib/packer-sync.js.map +1 -0
- package/dist/node_modules/pngjs/lib/packer.js +147 -0
- package/dist/node_modules/pngjs/lib/packer.js.map +1 -0
- package/dist/node_modules/pngjs/lib/paeth-predictor.js +28 -0
- package/dist/node_modules/pngjs/lib/paeth-predictor.js.map +1 -0
- package/dist/node_modules/pngjs/lib/parser-async.js +185 -0
- package/dist/node_modules/pngjs/lib/parser-async.js.map +1 -0
- package/dist/node_modules/pngjs/lib/parser-sync.js +128 -0
- package/dist/node_modules/pngjs/lib/parser-sync.js.map +1 -0
- package/dist/node_modules/pngjs/lib/parser.js +305 -0
- package/dist/node_modules/pngjs/lib/parser.js.map +1 -0
- package/dist/node_modules/pngjs/lib/png-sync.js +27 -0
- package/dist/node_modules/pngjs/lib/png-sync.js.map +1 -0
- package/dist/node_modules/pngjs/lib/png.js +212 -0
- package/dist/node_modules/pngjs/lib/png.js.map +1 -0
- package/dist/node_modules/pngjs/lib/sync-inflate.js +184 -0
- package/dist/node_modules/pngjs/lib/sync-inflate.js.map +1 -0
- package/dist/node_modules/pngjs/lib/sync-reader.js +58 -0
- package/dist/node_modules/pngjs/lib/sync-reader.js.map +1 -0
- package/dist/node_modules/qrcode/lib/browser.js +93 -0
- package/dist/node_modules/qrcode/lib/browser.js.map +1 -0
- package/dist/node_modules/qrcode/lib/can-promise.js +20 -0
- package/dist/node_modules/qrcode/lib/can-promise.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/alignment-pattern.js +100 -0
- package/dist/node_modules/qrcode/lib/core/alignment-pattern.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/alphanumeric-data.js +74 -0
- package/dist/node_modules/qrcode/lib/core/alphanumeric-data.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/bit-buffer.js +50 -0
- package/dist/node_modules/qrcode/lib/core/bit-buffer.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/bit-matrix.js +79 -0
- package/dist/node_modules/qrcode/lib/core/bit-matrix.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/byte-data.js +45 -0
- package/dist/node_modules/qrcode/lib/core/byte-data.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/error-correction-code.js +150 -0
- package/dist/node_modules/qrcode/lib/core/error-correction-code.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/error-correction-level.js +66 -0
- package/dist/node_modules/qrcode/lib/core/error-correction-level.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/finder-pattern.js +37 -0
- package/dist/node_modules/qrcode/lib/core/finder-pattern.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/format-info.js +44 -0
- package/dist/node_modules/qrcode/lib/core/format-info.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/galois-field.js +83 -0
- package/dist/node_modules/qrcode/lib/core/galois-field.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/kanji-data.js +70 -0
- package/dist/node_modules/qrcode/lib/core/kanji-data.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/mask-pattern.js +251 -0
- package/dist/node_modules/qrcode/lib/core/mask-pattern.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/mode.js +185 -0
- package/dist/node_modules/qrcode/lib/core/mode.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/numeric-data.js +58 -0
- package/dist/node_modules/qrcode/lib/core/numeric-data.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/polynomial.js +79 -0
- package/dist/node_modules/qrcode/lib/core/polynomial.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/qrcode.js +522 -0
- package/dist/node_modules/qrcode/lib/core/qrcode.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.js +71 -0
- package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/regex.js +45 -0
- package/dist/node_modules/qrcode/lib/core/regex.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/segments.js +354 -0
- package/dist/node_modules/qrcode/lib/core/segments.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/utils.js +77 -0
- package/dist/node_modules/qrcode/lib/core/utils.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/version-check.js +24 -0
- package/dist/node_modules/qrcode/lib/core/version-check.js.map +1 -0
- package/dist/node_modules/qrcode/lib/core/version.js +184 -0
- package/dist/node_modules/qrcode/lib/core/version.js.map +1 -0
- package/dist/node_modules/qrcode/lib/index.js +27 -0
- package/dist/node_modules/qrcode/lib/index.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/canvas.js +80 -0
- package/dist/node_modules/qrcode/lib/renderer/canvas.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/png.js +97 -0
- package/dist/node_modules/qrcode/lib/renderer/png.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/svg-tag.js +96 -0
- package/dist/node_modules/qrcode/lib/renderer/svg-tag.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/svg.js +37 -0
- package/dist/node_modules/qrcode/lib/renderer/svg.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +99 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal/terminal-small.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal/terminal.js +63 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal/terminal.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal.js +25 -0
- package/dist/node_modules/qrcode/lib/renderer/terminal.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/utf8.js +89 -0
- package/dist/node_modules/qrcode/lib/renderer/utf8.js.map +1 -0
- package/dist/node_modules/qrcode/lib/renderer/utils.js +115 -0
- package/dist/node_modules/qrcode/lib/renderer/utils.js.map +1 -0
- package/dist/node_modules/qrcode/lib/server.js +159 -0
- package/dist/node_modules/qrcode/lib/server.js.map +1 -0
- package/dist/package.json.js +3 -2
- package/dist/package.json.js.map +1 -1
- package/dist/utils/config.js +2 -2
- package/dist/utils/config.js.map +1 -1
- package/dist/utils/qrcode.d.ts.map +1 -1
- package/dist/utils/qrcode.js +5 -9
- package/dist/utils/qrcode.js.map +1 -1
- package/package.json +3 -2
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var filterParse = require('../../../_virtual/filter-parse.js');
|
|
4
|
+
var interlace = require('./interlace.js');
|
|
5
|
+
var paethPredictor = require('./paeth-predictor.js');
|
|
6
|
+
|
|
7
|
+
var hasRequiredFilterParse;
|
|
8
|
+
|
|
9
|
+
function requireFilterParse () {
|
|
10
|
+
if (hasRequiredFilterParse) return filterParse.__module.exports;
|
|
11
|
+
hasRequiredFilterParse = 1;
|
|
12
|
+
|
|
13
|
+
let interlaceUtils = interlace.__require();
|
|
14
|
+
let paethPredictor$1 = paethPredictor.__require();
|
|
15
|
+
|
|
16
|
+
function getByteWidth(width, bpp, depth) {
|
|
17
|
+
let byteWidth = width * bpp;
|
|
18
|
+
if (depth !== 8) {
|
|
19
|
+
byteWidth = Math.ceil(byteWidth / (8 / depth));
|
|
20
|
+
}
|
|
21
|
+
return byteWidth;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
let Filter = (filterParse.__module.exports = function (bitmapInfo, dependencies) {
|
|
25
|
+
let width = bitmapInfo.width;
|
|
26
|
+
let height = bitmapInfo.height;
|
|
27
|
+
let interlace = bitmapInfo.interlace;
|
|
28
|
+
let bpp = bitmapInfo.bpp;
|
|
29
|
+
let depth = bitmapInfo.depth;
|
|
30
|
+
|
|
31
|
+
this.read = dependencies.read;
|
|
32
|
+
this.write = dependencies.write;
|
|
33
|
+
this.complete = dependencies.complete;
|
|
34
|
+
|
|
35
|
+
this._imageIndex = 0;
|
|
36
|
+
this._images = [];
|
|
37
|
+
if (interlace) {
|
|
38
|
+
let passes = interlaceUtils.getImagePasses(width, height);
|
|
39
|
+
for (let i = 0; i < passes.length; i++) {
|
|
40
|
+
this._images.push({
|
|
41
|
+
byteWidth: getByteWidth(passes[i].width, bpp, depth),
|
|
42
|
+
height: passes[i].height,
|
|
43
|
+
lineIndex: 0,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
this._images.push({
|
|
48
|
+
byteWidth: getByteWidth(width, bpp, depth),
|
|
49
|
+
height: height,
|
|
50
|
+
lineIndex: 0,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// when filtering the line we look at the pixel to the left
|
|
55
|
+
// the spec also says it is done on a byte level regardless of the number of pixels
|
|
56
|
+
// so if the depth is byte compatible (8 or 16) we subtract the bpp in order to compare back
|
|
57
|
+
// a pixel rather than just a different byte part. However if we are sub byte, we ignore.
|
|
58
|
+
if (depth === 8) {
|
|
59
|
+
this._xComparison = bpp;
|
|
60
|
+
} else if (depth === 16) {
|
|
61
|
+
this._xComparison = bpp * 2;
|
|
62
|
+
} else {
|
|
63
|
+
this._xComparison = 1;
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
Filter.prototype.start = function () {
|
|
68
|
+
this.read(
|
|
69
|
+
this._images[this._imageIndex].byteWidth + 1,
|
|
70
|
+
this._reverseFilterLine.bind(this)
|
|
71
|
+
);
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
Filter.prototype._unFilterType1 = function (
|
|
75
|
+
rawData,
|
|
76
|
+
unfilteredLine,
|
|
77
|
+
byteWidth
|
|
78
|
+
) {
|
|
79
|
+
let xComparison = this._xComparison;
|
|
80
|
+
let xBiggerThan = xComparison - 1;
|
|
81
|
+
|
|
82
|
+
for (let x = 0; x < byteWidth; x++) {
|
|
83
|
+
let rawByte = rawData[1 + x];
|
|
84
|
+
let f1Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;
|
|
85
|
+
unfilteredLine[x] = rawByte + f1Left;
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
Filter.prototype._unFilterType2 = function (
|
|
90
|
+
rawData,
|
|
91
|
+
unfilteredLine,
|
|
92
|
+
byteWidth
|
|
93
|
+
) {
|
|
94
|
+
let lastLine = this._lastLine;
|
|
95
|
+
|
|
96
|
+
for (let x = 0; x < byteWidth; x++) {
|
|
97
|
+
let rawByte = rawData[1 + x];
|
|
98
|
+
let f2Up = lastLine ? lastLine[x] : 0;
|
|
99
|
+
unfilteredLine[x] = rawByte + f2Up;
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
|
|
103
|
+
Filter.prototype._unFilterType3 = function (
|
|
104
|
+
rawData,
|
|
105
|
+
unfilteredLine,
|
|
106
|
+
byteWidth
|
|
107
|
+
) {
|
|
108
|
+
let xComparison = this._xComparison;
|
|
109
|
+
let xBiggerThan = xComparison - 1;
|
|
110
|
+
let lastLine = this._lastLine;
|
|
111
|
+
|
|
112
|
+
for (let x = 0; x < byteWidth; x++) {
|
|
113
|
+
let rawByte = rawData[1 + x];
|
|
114
|
+
let f3Up = lastLine ? lastLine[x] : 0;
|
|
115
|
+
let f3Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;
|
|
116
|
+
let f3Add = Math.floor((f3Left + f3Up) / 2);
|
|
117
|
+
unfilteredLine[x] = rawByte + f3Add;
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
Filter.prototype._unFilterType4 = function (
|
|
122
|
+
rawData,
|
|
123
|
+
unfilteredLine,
|
|
124
|
+
byteWidth
|
|
125
|
+
) {
|
|
126
|
+
let xComparison = this._xComparison;
|
|
127
|
+
let xBiggerThan = xComparison - 1;
|
|
128
|
+
let lastLine = this._lastLine;
|
|
129
|
+
|
|
130
|
+
for (let x = 0; x < byteWidth; x++) {
|
|
131
|
+
let rawByte = rawData[1 + x];
|
|
132
|
+
let f4Up = lastLine ? lastLine[x] : 0;
|
|
133
|
+
let f4Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;
|
|
134
|
+
let f4UpLeft = x > xBiggerThan && lastLine ? lastLine[x - xComparison] : 0;
|
|
135
|
+
let f4Add = paethPredictor$1(f4Left, f4Up, f4UpLeft);
|
|
136
|
+
unfilteredLine[x] = rawByte + f4Add;
|
|
137
|
+
}
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
Filter.prototype._reverseFilterLine = function (rawData) {
|
|
141
|
+
let filter = rawData[0];
|
|
142
|
+
let unfilteredLine;
|
|
143
|
+
let currentImage = this._images[this._imageIndex];
|
|
144
|
+
let byteWidth = currentImage.byteWidth;
|
|
145
|
+
|
|
146
|
+
if (filter === 0) {
|
|
147
|
+
unfilteredLine = rawData.slice(1, byteWidth + 1);
|
|
148
|
+
} else {
|
|
149
|
+
unfilteredLine = Buffer.alloc(byteWidth);
|
|
150
|
+
|
|
151
|
+
switch (filter) {
|
|
152
|
+
case 1:
|
|
153
|
+
this._unFilterType1(rawData, unfilteredLine, byteWidth);
|
|
154
|
+
break;
|
|
155
|
+
case 2:
|
|
156
|
+
this._unFilterType2(rawData, unfilteredLine, byteWidth);
|
|
157
|
+
break;
|
|
158
|
+
case 3:
|
|
159
|
+
this._unFilterType3(rawData, unfilteredLine, byteWidth);
|
|
160
|
+
break;
|
|
161
|
+
case 4:
|
|
162
|
+
this._unFilterType4(rawData, unfilteredLine, byteWidth);
|
|
163
|
+
break;
|
|
164
|
+
default:
|
|
165
|
+
throw new Error("Unrecognised filter type - " + filter);
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
this.write(unfilteredLine);
|
|
170
|
+
|
|
171
|
+
currentImage.lineIndex++;
|
|
172
|
+
if (currentImage.lineIndex >= currentImage.height) {
|
|
173
|
+
this._lastLine = null;
|
|
174
|
+
this._imageIndex++;
|
|
175
|
+
currentImage = this._images[this._imageIndex];
|
|
176
|
+
} else {
|
|
177
|
+
this._lastLine = unfilteredLine;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (currentImage) {
|
|
181
|
+
// read, using the byte width that may be from the new current image
|
|
182
|
+
this.read(currentImage.byteWidth + 1, this._reverseFilterLine.bind(this));
|
|
183
|
+
} else {
|
|
184
|
+
this._lastLine = null;
|
|
185
|
+
this.complete();
|
|
186
|
+
}
|
|
187
|
+
};
|
|
188
|
+
return filterParse.__module.exports;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
exports.__require = requireFilterParse;
|
|
192
|
+
//# sourceMappingURL=filter-parse.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"filter-parse.js","sources":["../../../../node_modules/pngjs/lib/filter-parse.js"],"sourcesContent":["\"use strict\";\n\nlet interlaceUtils = require(\"./interlace\");\nlet paethPredictor = require(\"./paeth-predictor\");\n\nfunction getByteWidth(width, bpp, depth) {\n let byteWidth = width * bpp;\n if (depth !== 8) {\n byteWidth = Math.ceil(byteWidth / (8 / depth));\n }\n return byteWidth;\n}\n\nlet Filter = (module.exports = function (bitmapInfo, dependencies) {\n let width = bitmapInfo.width;\n let height = bitmapInfo.height;\n let interlace = bitmapInfo.interlace;\n let bpp = bitmapInfo.bpp;\n let depth = bitmapInfo.depth;\n\n this.read = dependencies.read;\n this.write = dependencies.write;\n this.complete = dependencies.complete;\n\n this._imageIndex = 0;\n this._images = [];\n if (interlace) {\n let passes = interlaceUtils.getImagePasses(width, height);\n for (let i = 0; i < passes.length; i++) {\n this._images.push({\n byteWidth: getByteWidth(passes[i].width, bpp, depth),\n height: passes[i].height,\n lineIndex: 0,\n });\n }\n } else {\n this._images.push({\n byteWidth: getByteWidth(width, bpp, depth),\n height: height,\n lineIndex: 0,\n });\n }\n\n // when filtering the line we look at the pixel to the left\n // the spec also says it is done on a byte level regardless of the number of pixels\n // so if the depth is byte compatible (8 or 16) we subtract the bpp in order to compare back\n // a pixel rather than just a different byte part. However if we are sub byte, we ignore.\n if (depth === 8) {\n this._xComparison = bpp;\n } else if (depth === 16) {\n this._xComparison = bpp * 2;\n } else {\n this._xComparison = 1;\n }\n});\n\nFilter.prototype.start = function () {\n this.read(\n this._images[this._imageIndex].byteWidth + 1,\n this._reverseFilterLine.bind(this)\n );\n};\n\nFilter.prototype._unFilterType1 = function (\n rawData,\n unfilteredLine,\n byteWidth\n) {\n let xComparison = this._xComparison;\n let xBiggerThan = xComparison - 1;\n\n for (let x = 0; x < byteWidth; x++) {\n let rawByte = rawData[1 + x];\n let f1Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;\n unfilteredLine[x] = rawByte + f1Left;\n }\n};\n\nFilter.prototype._unFilterType2 = function (\n rawData,\n unfilteredLine,\n byteWidth\n) {\n let lastLine = this._lastLine;\n\n for (let x = 0; x < byteWidth; x++) {\n let rawByte = rawData[1 + x];\n let f2Up = lastLine ? lastLine[x] : 0;\n unfilteredLine[x] = rawByte + f2Up;\n }\n};\n\nFilter.prototype._unFilterType3 = function (\n rawData,\n unfilteredLine,\n byteWidth\n) {\n let xComparison = this._xComparison;\n let xBiggerThan = xComparison - 1;\n let lastLine = this._lastLine;\n\n for (let x = 0; x < byteWidth; x++) {\n let rawByte = rawData[1 + x];\n let f3Up = lastLine ? lastLine[x] : 0;\n let f3Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;\n let f3Add = Math.floor((f3Left + f3Up) / 2);\n unfilteredLine[x] = rawByte + f3Add;\n }\n};\n\nFilter.prototype._unFilterType4 = function (\n rawData,\n unfilteredLine,\n byteWidth\n) {\n let xComparison = this._xComparison;\n let xBiggerThan = xComparison - 1;\n let lastLine = this._lastLine;\n\n for (let x = 0; x < byteWidth; x++) {\n let rawByte = rawData[1 + x];\n let f4Up = lastLine ? lastLine[x] : 0;\n let f4Left = x > xBiggerThan ? unfilteredLine[x - xComparison] : 0;\n let f4UpLeft = x > xBiggerThan && lastLine ? lastLine[x - xComparison] : 0;\n let f4Add = paethPredictor(f4Left, f4Up, f4UpLeft);\n unfilteredLine[x] = rawByte + f4Add;\n }\n};\n\nFilter.prototype._reverseFilterLine = function (rawData) {\n let filter = rawData[0];\n let unfilteredLine;\n let currentImage = this._images[this._imageIndex];\n let byteWidth = currentImage.byteWidth;\n\n if (filter === 0) {\n unfilteredLine = rawData.slice(1, byteWidth + 1);\n } else {\n unfilteredLine = Buffer.alloc(byteWidth);\n\n switch (filter) {\n case 1:\n this._unFilterType1(rawData, unfilteredLine, byteWidth);\n break;\n case 2:\n this._unFilterType2(rawData, unfilteredLine, byteWidth);\n break;\n case 3:\n this._unFilterType3(rawData, unfilteredLine, byteWidth);\n break;\n case 4:\n this._unFilterType4(rawData, unfilteredLine, byteWidth);\n break;\n default:\n throw new Error(\"Unrecognised filter type - \" + filter);\n }\n }\n\n this.write(unfilteredLine);\n\n currentImage.lineIndex++;\n if (currentImage.lineIndex >= currentImage.height) {\n this._lastLine = null;\n this._imageIndex++;\n currentImage = this._images[this._imageIndex];\n } else {\n this._lastLine = unfilteredLine;\n }\n\n if (currentImage) {\n // read, using the byte width that may be from the new current image\n this.read(currentImage.byteWidth + 1, this._reverseFilterLine.bind(this));\n } else {\n this._lastLine = null;\n this.complete();\n }\n};\n"],"names":["require$$0","paethPredictor","require$$1","filterParseModule"],"mappings":";;;;;;;;;;;;CAEA,IAAI,cAAc,GAAGA,mBAAA,EAAsB;CAC3C,IAAIC,gBAAc,GAAGC,wBAAA,EAA4B;;AAEjD,CAAA,SAAS,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE;AACzC,GAAE,IAAI,SAAS,GAAG,KAAK,GAAG,GAAG;AAC7B,GAAE,IAAI,KAAK,KAAK,CAAC,EAAE;AACnB,KAAI,SAAS,GAAG,IAAI,CAAC,IAAI,CAAC,SAAS,IAAI,CAAC,GAAG,KAAK,CAAC,CAAC;AAClD,GAAA;AACA,GAAE,OAAO,SAAS;AAClB,CAAA;;CAEA,IAAI,MAAM,IAAIC,oBAAA,CAAA,OAAc,GAAG,UAAU,UAAU,EAAE,YAAY,EAAE;AACnE,GAAE,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK;AAC9B,GAAE,IAAI,MAAM,GAAG,UAAU,CAA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AAI,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC;SACvD;AACR,OAAM,KAAK,CAAC;SACJ,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,cAAc,EAAE,SAAS,CAAC;SACvD;OACF;AACN,SAAQ,MAAM,IAAI,KAAK,CAAC,6BAA6B,GAAG,MAAM,CAAC;AAC/D;AACA,GAAA;;AAEA,GAAE,IAAI,CAAC,KAAK,CAAC,cAAc,CAAC;;GAE1B,YAAY,CAAC,SAAS,EAAE;GACxB,IAAI,YAAY,CAAC,SAAS,IAAI,YAAY,CAAC,MAAM,EAAE;AACrD,KAAI,IAAI,CAAC,SAAS,GAAG,IAAI;KACrB,IAAI,CAAC,WAAW,EAAE;KAClB,YAAY,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,WAAW,CAAC;AACjD,GAAA,CAAG,MAAM;AACT,KAAI,IAAI,CAAC,SAAS,GAAG,cAAc;AACnC,GAAA;;GAEE,IAAI,YAAY,EAAE;AACpB;AACA,KAAI,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,SAAS,GAAG,CAAC,EAAE,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC7E,GAAA,CAAG,MAAM;AACT,KAAI,IAAI,CAAC,SAAS,GAAG,IAAI;KACrB,IAAI,CAAC,QAAQ,EAAE;AACnB,GAAA;CACA,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var formatNormaliser;
|
|
4
|
+
var hasRequiredFormatNormaliser;
|
|
5
|
+
|
|
6
|
+
function requireFormatNormaliser () {
|
|
7
|
+
if (hasRequiredFormatNormaliser) return formatNormaliser;
|
|
8
|
+
hasRequiredFormatNormaliser = 1;
|
|
9
|
+
|
|
10
|
+
function dePalette(indata, outdata, width, height, palette) {
|
|
11
|
+
let pxPos = 0;
|
|
12
|
+
// use values from palette
|
|
13
|
+
for (let y = 0; y < height; y++) {
|
|
14
|
+
for (let x = 0; x < width; x++) {
|
|
15
|
+
let color = palette[indata[pxPos]];
|
|
16
|
+
|
|
17
|
+
if (!color) {
|
|
18
|
+
throw new Error("index " + indata[pxPos] + " not in palette");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
for (let i = 0; i < 4; i++) {
|
|
22
|
+
outdata[pxPos + i] = color[i];
|
|
23
|
+
}
|
|
24
|
+
pxPos += 4;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function replaceTransparentColor(indata, outdata, width, height, transColor) {
|
|
30
|
+
let pxPos = 0;
|
|
31
|
+
for (let y = 0; y < height; y++) {
|
|
32
|
+
for (let x = 0; x < width; x++) {
|
|
33
|
+
let makeTrans = false;
|
|
34
|
+
|
|
35
|
+
if (transColor.length === 1) {
|
|
36
|
+
if (transColor[0] === indata[pxPos]) {
|
|
37
|
+
makeTrans = true;
|
|
38
|
+
}
|
|
39
|
+
} else if (
|
|
40
|
+
transColor[0] === indata[pxPos] &&
|
|
41
|
+
transColor[1] === indata[pxPos + 1] &&
|
|
42
|
+
transColor[2] === indata[pxPos + 2]
|
|
43
|
+
) {
|
|
44
|
+
makeTrans = true;
|
|
45
|
+
}
|
|
46
|
+
if (makeTrans) {
|
|
47
|
+
for (let i = 0; i < 4; i++) {
|
|
48
|
+
outdata[pxPos + i] = 0;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
pxPos += 4;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function scaleDepth(indata, outdata, width, height, depth) {
|
|
57
|
+
let maxOutSample = 255;
|
|
58
|
+
let maxInSample = Math.pow(2, depth) - 1;
|
|
59
|
+
let pxPos = 0;
|
|
60
|
+
|
|
61
|
+
for (let y = 0; y < height; y++) {
|
|
62
|
+
for (let x = 0; x < width; x++) {
|
|
63
|
+
for (let i = 0; i < 4; i++) {
|
|
64
|
+
outdata[pxPos + i] = Math.floor(
|
|
65
|
+
(indata[pxPos + i] * maxOutSample) / maxInSample + 0.5
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
pxPos += 4;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
formatNormaliser = function (indata, imageData) {
|
|
74
|
+
let depth = imageData.depth;
|
|
75
|
+
let width = imageData.width;
|
|
76
|
+
let height = imageData.height;
|
|
77
|
+
let colorType = imageData.colorType;
|
|
78
|
+
let transColor = imageData.transColor;
|
|
79
|
+
let palette = imageData.palette;
|
|
80
|
+
|
|
81
|
+
let outdata = indata; // only different for 16 bits
|
|
82
|
+
|
|
83
|
+
if (colorType === 3) {
|
|
84
|
+
// paletted
|
|
85
|
+
dePalette(indata, outdata, width, height, palette);
|
|
86
|
+
} else {
|
|
87
|
+
if (transColor) {
|
|
88
|
+
replaceTransparentColor(indata, outdata, width, height, transColor);
|
|
89
|
+
}
|
|
90
|
+
// if it needs scaling
|
|
91
|
+
if (depth !== 8) {
|
|
92
|
+
// if we need to change the buffer size
|
|
93
|
+
if (depth === 16) {
|
|
94
|
+
outdata = Buffer.alloc(width * height * 4);
|
|
95
|
+
}
|
|
96
|
+
scaleDepth(indata, outdata, width, height, depth);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return outdata;
|
|
100
|
+
};
|
|
101
|
+
return formatNormaliser;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
exports.__require = requireFormatNormaliser;
|
|
105
|
+
//# sourceMappingURL=format-normaliser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"format-normaliser.js","sources":["../../../../node_modules/pngjs/lib/format-normaliser.js"],"sourcesContent":["\"use strict\";\n\nfunction dePalette(indata, outdata, width, height, palette) {\n let pxPos = 0;\n // use values from palette\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n let color = palette[indata[pxPos]];\n\n if (!color) {\n throw new Error(\"index \" + indata[pxPos] + \" not in palette\");\n }\n\n for (let i = 0; i < 4; i++) {\n outdata[pxPos + i] = color[i];\n }\n pxPos += 4;\n }\n }\n}\n\nfunction replaceTransparentColor(indata, outdata, width, height, transColor) {\n let pxPos = 0;\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n let makeTrans = false;\n\n if (transColor.length === 1) {\n if (transColor[0] === indata[pxPos]) {\n makeTrans = true;\n }\n } else if (\n transColor[0] === indata[pxPos] &&\n transColor[1] === indata[pxPos + 1] &&\n transColor[2] === indata[pxPos + 2]\n ) {\n makeTrans = true;\n }\n if (makeTrans) {\n for (let i = 0; i < 4; i++) {\n outdata[pxPos + i] = 0;\n }\n }\n pxPos += 4;\n }\n }\n}\n\nfunction scaleDepth(indata, outdata, width, height, depth) {\n let maxOutSample = 255;\n let maxInSample = Math.pow(2, depth) - 1;\n let pxPos = 0;\n\n for (let y = 0; y < height; y++) {\n for (let x = 0; x < width; x++) {\n for (let i = 0; i < 4; i++) {\n outdata[pxPos + i] = Math.floor(\n (indata[pxPos + i] * maxOutSample) / maxInSample + 0.5\n );\n }\n pxPos += 4;\n }\n }\n}\n\nmodule.exports = function (indata, imageData) {\n let depth = imageData.depth;\n let width = imageData.width;\n let height = imageData.height;\n let colorType = imageData.colorType;\n let transColor = imageData.transColor;\n let palette = imageData.palette;\n\n let outdata = indata; // only different for 16 bits\n\n if (colorType === 3) {\n // paletted\n dePalette(indata, outdata, width, height, palette);\n } else {\n if (transColor) {\n replaceTransparentColor(indata, outdata, width, height, transColor);\n }\n // if it needs scaling\n if (depth !== 8) {\n // if we need to change the buffer size\n if (depth === 16) {\n outdata = Buffer.alloc(width * height * 4);\n }\n scaleDepth(indata, outdata, width, height, depth);\n }\n }\n return outdata;\n};\n"],"names":[],"mappings":";;;;;;;;;CAEA,SAAS,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAA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9C,GAAE,IAAI,KAAK,GAAG,SAAS,CAAC,KAAK;AAC7B,GAAE,IAAI,KAAK,GAAG,SAAS,CAAC,KAAK;AAC7B,GAAE,IAAI,MAAM,GAAG,SAAS,CAAC,MAAM;AAC/B,GAAE,IAAI,SAAS,GAAG,SAAS,CAAC,SAAS;AACrC,GAAE,IAAI,UAAU,GAAG,SAAS,CAAC,UAAU;AACvC,GAAE,IAAI,OAAO,GAAG,SAAS,CAAC,OAAO;;AAEjC,GAAE,IAAI,OAAO,GAAG,MAAM,CAAC;;AAEvB,GAAE,IAAI,SAAS,KAAK,CAAC,EAAE;AACvB;KACI,SAAS,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC;AACtD,GAAA,CAAG,MAAM;KACL,IAAI,UAAU,EAAE;OACd,uBAAuB,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC;AACzE,KAAA;AACA;AACA,KAAI,IAAI,KAAK,KAAK,CAAC,EAAE;AACrB;AACA,OAAM,IAAI,KAAK,KAAK,EAAE,EAAE;SAChB,OAAO,GAAG,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,GAAG,CAAC,CAAC;AAClD,OAAA;OACM,UAAU,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,CAAC;AACvD,KAAA;AACA,GAAA;AACA,GAAE,OAAO,OAAO;CAChB,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var interlace = require('../../../_virtual/interlace.js');
|
|
4
|
+
|
|
5
|
+
var hasRequiredInterlace;
|
|
6
|
+
|
|
7
|
+
function requireInterlace () {
|
|
8
|
+
if (hasRequiredInterlace) return interlace.__exports;
|
|
9
|
+
hasRequiredInterlace = 1;
|
|
10
|
+
|
|
11
|
+
// Adam 7
|
|
12
|
+
// 0 1 2 3 4 5 6 7
|
|
13
|
+
// 0 x 6 4 6 x 6 4 6
|
|
14
|
+
// 1 7 7 7 7 7 7 7 7
|
|
15
|
+
// 2 5 6 5 6 5 6 5 6
|
|
16
|
+
// 3 7 7 7 7 7 7 7 7
|
|
17
|
+
// 4 3 6 4 6 3 6 4 6
|
|
18
|
+
// 5 7 7 7 7 7 7 7 7
|
|
19
|
+
// 6 5 6 5 6 5 6 5 6
|
|
20
|
+
// 7 7 7 7 7 7 7 7 7
|
|
21
|
+
|
|
22
|
+
let imagePasses = [
|
|
23
|
+
{
|
|
24
|
+
// pass 1 - 1px
|
|
25
|
+
x: [0],
|
|
26
|
+
y: [0],
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
// pass 2 - 1px
|
|
30
|
+
x: [4],
|
|
31
|
+
y: [0],
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
// pass 3 - 2px
|
|
35
|
+
x: [0, 4],
|
|
36
|
+
y: [4],
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
// pass 4 - 4px
|
|
40
|
+
x: [2, 6],
|
|
41
|
+
y: [0, 4],
|
|
42
|
+
},
|
|
43
|
+
{
|
|
44
|
+
// pass 5 - 8px
|
|
45
|
+
x: [0, 2, 4, 6],
|
|
46
|
+
y: [2, 6],
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
// pass 6 - 16px
|
|
50
|
+
x: [1, 3, 5, 7],
|
|
51
|
+
y: [0, 2, 4, 6],
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
// pass 7 - 32px
|
|
55
|
+
x: [0, 1, 2, 3, 4, 5, 6, 7],
|
|
56
|
+
y: [1, 3, 5, 7],
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
|
|
60
|
+
interlace.__exports.getImagePasses = function (width, height) {
|
|
61
|
+
let images = [];
|
|
62
|
+
let xLeftOver = width % 8;
|
|
63
|
+
let yLeftOver = height % 8;
|
|
64
|
+
let xRepeats = (width - xLeftOver) / 8;
|
|
65
|
+
let yRepeats = (height - yLeftOver) / 8;
|
|
66
|
+
for (let i = 0; i < imagePasses.length; i++) {
|
|
67
|
+
let pass = imagePasses[i];
|
|
68
|
+
let passWidth = xRepeats * pass.x.length;
|
|
69
|
+
let passHeight = yRepeats * pass.y.length;
|
|
70
|
+
for (let j = 0; j < pass.x.length; j++) {
|
|
71
|
+
if (pass.x[j] < xLeftOver) {
|
|
72
|
+
passWidth++;
|
|
73
|
+
} else {
|
|
74
|
+
break;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
for (let j = 0; j < pass.y.length; j++) {
|
|
78
|
+
if (pass.y[j] < yLeftOver) {
|
|
79
|
+
passHeight++;
|
|
80
|
+
} else {
|
|
81
|
+
break;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
if (passWidth > 0 && passHeight > 0) {
|
|
85
|
+
images.push({ width: passWidth, height: passHeight, index: i });
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
return images;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
interlace.__exports.getInterlaceIterator = function (width) {
|
|
92
|
+
return function (x, y, pass) {
|
|
93
|
+
let outerXLeftOver = x % imagePasses[pass].x.length;
|
|
94
|
+
let outerX =
|
|
95
|
+
((x - outerXLeftOver) / imagePasses[pass].x.length) * 8 +
|
|
96
|
+
imagePasses[pass].x[outerXLeftOver];
|
|
97
|
+
let outerYLeftOver = y % imagePasses[pass].y.length;
|
|
98
|
+
let outerY =
|
|
99
|
+
((y - outerYLeftOver) / imagePasses[pass].y.length) * 8 +
|
|
100
|
+
imagePasses[pass].y[outerYLeftOver];
|
|
101
|
+
return outerX * 4 + outerY * width * 4;
|
|
102
|
+
};
|
|
103
|
+
};
|
|
104
|
+
return interlace.__exports;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
exports.__require = requireInterlace;
|
|
108
|
+
//# sourceMappingURL=interlace.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interlace.js","sources":["../../../../node_modules/pngjs/lib/interlace.js"],"sourcesContent":["\"use strict\";\n\n// Adam 7\n// 0 1 2 3 4 5 6 7\n// 0 x 6 4 6 x 6 4 6\n// 1 7 7 7 7 7 7 7 7\n// 2 5 6 5 6 5 6 5 6\n// 3 7 7 7 7 7 7 7 7\n// 4 3 6 4 6 3 6 4 6\n// 5 7 7 7 7 7 7 7 7\n// 6 5 6 5 6 5 6 5 6\n// 7 7 7 7 7 7 7 7 7\n\nlet imagePasses = [\n {\n // pass 1 - 1px\n x: [0],\n y: [0],\n },\n {\n // pass 2 - 1px\n x: [4],\n y: [0],\n },\n {\n // pass 3 - 2px\n x: [0, 4],\n y: [4],\n },\n {\n // pass 4 - 4px\n x: [2, 6],\n y: [0, 4],\n },\n {\n // pass 5 - 8px\n x: [0, 2, 4, 6],\n y: [2, 6],\n },\n {\n // pass 6 - 16px\n x: [1, 3, 5, 7],\n y: [0, 2, 4, 6],\n },\n {\n // pass 7 - 32px\n x: [0, 1, 2, 3, 4, 5, 6, 7],\n y: [1, 3, 5, 7],\n },\n];\n\nexports.getImagePasses = function (width, height) {\n let images = [];\n let xLeftOver = width % 8;\n let yLeftOver = height % 8;\n let xRepeats = (width - xLeftOver) / 8;\n let yRepeats = (height - yLeftOver) / 8;\n for (let i = 0; i < imagePasses.length; i++) {\n let pass = imagePasses[i];\n let passWidth = xRepeats * pass.x.length;\n let passHeight = yRepeats * pass.y.length;\n for (let j = 0; j < pass.x.length; j++) {\n if (pass.x[j] < xLeftOver) {\n passWidth++;\n } else {\n break;\n }\n }\n for (let j = 0; j < pass.y.length; j++) {\n if (pass.y[j] < yLeftOver) {\n passHeight++;\n } else {\n break;\n }\n }\n if (passWidth > 0 && passHeight > 0) {\n images.push({ width: passWidth, height: passHeight, index: i });\n }\n }\n return images;\n};\n\nexports.getInterlaceIterator = function (width) {\n return function (x, y, pass) {\n let outerXLeftOver = x % imagePasses[pass].x.length;\n let outerX =\n ((x - outerXLeftOver) / imagePasses[pass].x.length) * 8 +\n imagePasses[pass].x[outerXLeftOver];\n let outerYLeftOver = y % imagePasses[pass].y.length;\n let outerY =\n ((y - outerYLeftOver) / imagePasses[pass].y.length) * 8 +\n imagePasses[pass].y[outerYLeftOver];\n return outerX * 4 + outerY * width * 4;\n };\n};\n"],"names":["interlace"],"mappings":";;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,CAAA,IAAI,WAAW,GAAG;GAChB;AACF;AACA,KAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,KAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACP;GACD;AACF;AACA,KAAI,CAAC,EAAE,CAAC,CAAC,CAAC;AACV,KAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACP;GACD;AACF;AACA,KAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACb,KAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IACP;GACD;AACF;AACA,KAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;AACb,KAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACV;GACD;AACF;KACI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;AACnB,KAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC;IACV;GACD;AACF;KACI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KACf,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;IAChB;GACD;AACF;AACA,KAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;KAC3B,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EA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AC,IAAI,CAAC,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC;AACrE,KAAA;AACA,GAAA;AACA,GAAE,OAAO,MAAM;CACf,CAAC;;AAED,CAAAA,mBAAA,CAAA,oBAA4B,GAAG,UAAU,KAAK,EAAE;AAChD,GAAE,OAAO,UAAU,CAAC,EAAE,CAAC,EAAE,IAAI,EAAE;AAC/B,KAAI,IAAI,cAAc,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;AACvD,KAAI,IAAI,MAAM;AACd,OAAM,CAAC,CAAC,CAAC,GAAG,cAAc,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC;OACvD,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;AACzC,KAAI,IAAI,cAAc,GAAG,CAAC,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM;AACvD,KAAI,IAAI,MAAM;AACd,OAAM,CAAC,CAAC,CAAC,GAAG,cAAc,IAAI,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC;OACvD,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC;KACrC,OAAO,MAAM,GAAG,CAAC,GAAG,MAAM,GAAG,KAAK,GAAG,CAAC;GAC1C,CAAG;CACH,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var packerAsync = require('../../../_virtual/packer-async.js');
|
|
4
|
+
var require$$0 = require('util');
|
|
5
|
+
var require$$1 = require('stream');
|
|
6
|
+
var constants = require('./constants.js');
|
|
7
|
+
var packer = require('./packer.js');
|
|
8
|
+
|
|
9
|
+
var hasRequiredPackerAsync;
|
|
10
|
+
|
|
11
|
+
function requirePackerAsync () {
|
|
12
|
+
if (hasRequiredPackerAsync) return packerAsync.__module.exports;
|
|
13
|
+
hasRequiredPackerAsync = 1;
|
|
14
|
+
|
|
15
|
+
let util = require$$0;
|
|
16
|
+
let Stream = require$$1;
|
|
17
|
+
let constants$1 = constants.__require();
|
|
18
|
+
let Packer = packer.__require();
|
|
19
|
+
|
|
20
|
+
let PackerAsync = (packerAsync.__module.exports = function (opt) {
|
|
21
|
+
Stream.call(this);
|
|
22
|
+
|
|
23
|
+
let options = opt || {};
|
|
24
|
+
|
|
25
|
+
this._packer = new Packer(options);
|
|
26
|
+
this._deflate = this._packer.createDeflate();
|
|
27
|
+
|
|
28
|
+
this.readable = true;
|
|
29
|
+
});
|
|
30
|
+
util.inherits(PackerAsync, Stream);
|
|
31
|
+
|
|
32
|
+
PackerAsync.prototype.pack = function (data, width, height, gamma) {
|
|
33
|
+
// Signature
|
|
34
|
+
this.emit("data", Buffer.from(constants$1.PNG_SIGNATURE));
|
|
35
|
+
this.emit("data", this._packer.packIHDR(width, height));
|
|
36
|
+
|
|
37
|
+
if (gamma) {
|
|
38
|
+
this.emit("data", this._packer.packGAMA(gamma));
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
let filteredData = this._packer.filterData(data, width, height);
|
|
42
|
+
|
|
43
|
+
// compress it
|
|
44
|
+
this._deflate.on("error", this.emit.bind(this, "error"));
|
|
45
|
+
|
|
46
|
+
this._deflate.on(
|
|
47
|
+
"data",
|
|
48
|
+
function (compressedData) {
|
|
49
|
+
this.emit("data", this._packer.packIDAT(compressedData));
|
|
50
|
+
}.bind(this)
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
this._deflate.on(
|
|
54
|
+
"end",
|
|
55
|
+
function () {
|
|
56
|
+
this.emit("data", this._packer.packIEND());
|
|
57
|
+
this.emit("end");
|
|
58
|
+
}.bind(this)
|
|
59
|
+
);
|
|
60
|
+
|
|
61
|
+
this._deflate.end(filteredData);
|
|
62
|
+
};
|
|
63
|
+
return packerAsync.__module.exports;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
exports.__require = requirePackerAsync;
|
|
67
|
+
//# sourceMappingURL=packer-async.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packer-async.js","sources":["../../../../node_modules/pngjs/lib/packer-async.js"],"sourcesContent":["\"use strict\";\n\nlet util = require(\"util\");\nlet Stream = require(\"stream\");\nlet constants = require(\"./constants\");\nlet Packer = require(\"./packer\");\n\nlet PackerAsync = (module.exports = function (opt) {\n Stream.call(this);\n\n let options = opt || {};\n\n this._packer = new Packer(options);\n this._deflate = this._packer.createDeflate();\n\n this.readable = true;\n});\nutil.inherits(PackerAsync, Stream);\n\nPackerAsync.prototype.pack = function (data, width, height, gamma) {\n // Signature\n this.emit(\"data\", Buffer.from(constants.PNG_SIGNATURE));\n this.emit(\"data\", this._packer.packIHDR(width, height));\n\n if (gamma) {\n this.emit(\"data\", this._packer.packGAMA(gamma));\n }\n\n let filteredData = this._packer.filterData(data, width, height);\n\n // compress it\n this._deflate.on(\"error\", this.emit.bind(this, \"error\"));\n\n this._deflate.on(\n \"data\",\n function (compressedData) {\n this.emit(\"data\", this._packer.packIDAT(compressedData));\n }.bind(this)\n );\n\n this._deflate.on(\n \"end\",\n function () {\n this.emit(\"data\", this._packer.packIEND());\n this.emit(\"end\");\n }.bind(this)\n );\n\n this._deflate.end(filteredData);\n};\n"],"names":["constants","require$$2","require$$3","packerAsyncModule"],"mappings":";;;;;;;;;;;;;;CAEA,IAAI,IAAI,GAAG,UAAe;CAC1B,IAAI,MAAM,GAAG,UAAiB;CAC9B,IAAIA,WAAS,GAAGC,mBAAA,EAAsB;CACtC,IAAI,MAAM,GAAGC,gBAAA,EAAmB;;AAEhC,CAAA,IAAI,WAAW,IAAIC,oBAAA,CAAA,OAAc,GAAG,UAAU,GAAG,EAAE;AACnD,GAAE,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC;;AAEnB,GAAE,IAAI,OAAO,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AAE,IAAI,CAAC,QAAQ,CAAC,EAAE;AAClB,KAAI,KAAK;AACT,KAAI,YAAY;AAChB,OAAM,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,OAAO,CAAC,QAAQ,EAAE,CAAC;AAChD,OAAM,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC;KACtB,CAAK,CAAC,IAAI,CAAC,IAAI;IACZ;;AAEH,GAAE,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,YAAY,CAAC;CACjC,CAAC;;;;;;","x_google_ignoreList":[0]}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var require$$1 = require('zlib');
|
|
4
|
+
var constants = require('./constants.js');
|
|
5
|
+
var packer = require('./packer.js');
|
|
6
|
+
|
|
7
|
+
var packerSync;
|
|
8
|
+
var hasRequiredPackerSync;
|
|
9
|
+
|
|
10
|
+
function requirePackerSync () {
|
|
11
|
+
if (hasRequiredPackerSync) return packerSync;
|
|
12
|
+
hasRequiredPackerSync = 1;
|
|
13
|
+
|
|
14
|
+
let hasSyncZlib = true;
|
|
15
|
+
let zlib = require$$1;
|
|
16
|
+
if (!zlib.deflateSync) {
|
|
17
|
+
hasSyncZlib = false;
|
|
18
|
+
}
|
|
19
|
+
let constants$1 = constants.__require();
|
|
20
|
+
let Packer = packer.__require();
|
|
21
|
+
|
|
22
|
+
packerSync = function (metaData, opt) {
|
|
23
|
+
if (!hasSyncZlib) {
|
|
24
|
+
throw new Error(
|
|
25
|
+
"To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0"
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
let options = opt || {};
|
|
30
|
+
|
|
31
|
+
let packer = new Packer(options);
|
|
32
|
+
|
|
33
|
+
let chunks = [];
|
|
34
|
+
|
|
35
|
+
// Signature
|
|
36
|
+
chunks.push(Buffer.from(constants$1.PNG_SIGNATURE));
|
|
37
|
+
|
|
38
|
+
// Header
|
|
39
|
+
chunks.push(packer.packIHDR(metaData.width, metaData.height));
|
|
40
|
+
|
|
41
|
+
if (metaData.gamma) {
|
|
42
|
+
chunks.push(packer.packGAMA(metaData.gamma));
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
let filteredData = packer.filterData(
|
|
46
|
+
metaData.data,
|
|
47
|
+
metaData.width,
|
|
48
|
+
metaData.height
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
// compress it
|
|
52
|
+
let compressedData = zlib.deflateSync(
|
|
53
|
+
filteredData,
|
|
54
|
+
packer.getDeflateOptions()
|
|
55
|
+
);
|
|
56
|
+
filteredData = null;
|
|
57
|
+
|
|
58
|
+
if (!compressedData || !compressedData.length) {
|
|
59
|
+
throw new Error("bad png - invalid compressed data response");
|
|
60
|
+
}
|
|
61
|
+
chunks.push(packer.packIDAT(compressedData));
|
|
62
|
+
|
|
63
|
+
// End
|
|
64
|
+
chunks.push(packer.packIEND());
|
|
65
|
+
|
|
66
|
+
return Buffer.concat(chunks);
|
|
67
|
+
};
|
|
68
|
+
return packerSync;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
exports.__require = requirePackerSync;
|
|
72
|
+
//# sourceMappingURL=packer-sync.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"packer-sync.js","sources":["../../../../node_modules/pngjs/lib/packer-sync.js"],"sourcesContent":["\"use strict\";\n\nlet hasSyncZlib = true;\nlet zlib = require(\"zlib\");\nif (!zlib.deflateSync) {\n hasSyncZlib = false;\n}\nlet constants = require(\"./constants\");\nlet Packer = require(\"./packer\");\n\nmodule.exports = function (metaData, opt) {\n if (!hasSyncZlib) {\n throw new Error(\n \"To use the sync capability of this library in old node versions, please pin pngjs to v2.3.0\"\n );\n }\n\n let options = opt || {};\n\n let packer = new Packer(options);\n\n let chunks = [];\n\n // Signature\n chunks.push(Buffer.from(constants.PNG_SIGNATURE));\n\n // Header\n chunks.push(packer.packIHDR(metaData.width, metaData.height));\n\n if (metaData.gamma) {\n chunks.push(packer.packGAMA(metaData.gamma));\n }\n\n let filteredData = packer.filterData(\n metaData.data,\n metaData.width,\n metaData.height\n );\n\n // compress it\n let compressedData = zlib.deflateSync(\n filteredData,\n packer.getDeflateOptions()\n );\n filteredData = null;\n\n if (!compressedData || !compressedData.length) {\n throw new Error(\"bad png - invalid compressed data response\");\n }\n chunks.push(packer.packIDAT(compressedData));\n\n // End\n chunks.push(packer.packIEND());\n\n return Buffer.concat(chunks);\n};\n"],"names":["require$$0","constants","require$$1","require$$2"],"mappings":";;;;;;;;;;;;;CAEA,IAAI,WAAW,GAAG,IAAI;CACtB,IAAI,IAAI,GAAGA,UAAe;AAC1B,CAAA,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE;GACrB,WAAW,GAAG,KAAK;AACrB,CAAA;CACA,IAAIC,WAAS,GAAGC,mBAAA,EAAsB;CACtC,IAAI,MAAM,GAAGC,gBAAA,EAAmB;;AAEhC,CAAA,UAAc,GAAG,UAAU,QAAQ,EAAE,GAAG,EAAE;GACxC,IAAI,CAAC,WAAW,EAAE;KAChB,MAAM,IAAI,KAAK;OACb;MACD;AACL,GAAA;;AAEA,GAAE,IAAI,OAAO,GAAG,GAAG,IAAI,EAAE;;AAEzB,GAAE,IAAI,MAAM,GAAG,IAAI,MAAM,CAAC,OAAO,CAAC;;GAEhC,IAAI,MAAM,GAAG,EAAE;;AAEjB;AACA,GAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAACF,WAAS,CAAC,aAAa,CAAC,CAAC;;AAEnD;AACA,GAAE,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,EAAE,QAAQ,CAAC,MAAM,CAAC,CAAC;;AAE/D,GAAE,IAAI,QAAQ,CAAC,KAAK,EAAE;AACtB,KAAI,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAAC,KAAK,CAAC,C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