@wecom/wecom-openclaw-cli 1.0.14 → 1.0.16

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.
Files changed (210) hide show
  1. package/dist/_virtual/_commonjsHelpers.js +8 -0
  2. package/dist/_virtual/_commonjsHelpers.js.map +1 -0
  3. package/dist/_virtual/alignment-pattern.js +6 -0
  4. package/dist/_virtual/alignment-pattern.js.map +1 -0
  5. package/dist/_virtual/bitmapper.js +6 -0
  6. package/dist/_virtual/bitmapper.js.map +1 -0
  7. package/dist/_virtual/browser.js +6 -0
  8. package/dist/_virtual/browser.js.map +1 -0
  9. package/dist/_virtual/canvas.js +6 -0
  10. package/dist/_virtual/canvas.js.map +1 -0
  11. package/dist/_virtual/chunkstream.js +6 -0
  12. package/dist/_virtual/chunkstream.js.map +1 -0
  13. package/dist/_virtual/crc.js +6 -0
  14. package/dist/_virtual/crc.js.map +1 -0
  15. package/dist/_virtual/dijkstra.js +6 -0
  16. package/dist/_virtual/dijkstra.js.map +1 -0
  17. package/dist/_virtual/error-correction-code.js +6 -0
  18. package/dist/_virtual/error-correction-code.js.map +1 -0
  19. package/dist/_virtual/error-correction-level.js +6 -0
  20. package/dist/_virtual/error-correction-level.js.map +1 -0
  21. package/dist/_virtual/filter-parse-async.js +6 -0
  22. package/dist/_virtual/filter-parse-async.js.map +1 -0
  23. package/dist/_virtual/filter-parse-sync.js +6 -0
  24. package/dist/_virtual/filter-parse-sync.js.map +1 -0
  25. package/dist/_virtual/filter-parse.js +6 -0
  26. package/dist/_virtual/filter-parse.js.map +1 -0
  27. package/dist/_virtual/finder-pattern.js +6 -0
  28. package/dist/_virtual/finder-pattern.js.map +1 -0
  29. package/dist/_virtual/format-info.js +6 -0
  30. package/dist/_virtual/format-info.js.map +1 -0
  31. package/dist/_virtual/galois-field.js +6 -0
  32. package/dist/_virtual/galois-field.js.map +1 -0
  33. package/dist/_virtual/index.js +10 -0
  34. package/dist/_virtual/index.js.map +1 -0
  35. package/dist/_virtual/interlace.js +6 -0
  36. package/dist/_virtual/interlace.js.map +1 -0
  37. package/dist/_virtual/mask-pattern.js +6 -0
  38. package/dist/_virtual/mask-pattern.js.map +1 -0
  39. package/dist/_virtual/mode.js +6 -0
  40. package/dist/_virtual/mode.js.map +1 -0
  41. package/dist/_virtual/packer-async.js +6 -0
  42. package/dist/_virtual/packer-async.js.map +1 -0
  43. package/dist/_virtual/packer.js +6 -0
  44. package/dist/_virtual/packer.js.map +1 -0
  45. package/dist/_virtual/parser-async.js +6 -0
  46. package/dist/_virtual/parser-async.js.map +1 -0
  47. package/dist/_virtual/parser.js +6 -0
  48. package/dist/_virtual/parser.js.map +1 -0
  49. package/dist/_virtual/png-sync.js +6 -0
  50. package/dist/_virtual/png-sync.js.map +1 -0
  51. package/dist/_virtual/png.js +6 -0
  52. package/dist/_virtual/png.js.map +1 -0
  53. package/dist/_virtual/png2.js +6 -0
  54. package/dist/_virtual/png2.js.map +1 -0
  55. package/dist/_virtual/polynomial.js +6 -0
  56. package/dist/_virtual/polynomial.js.map +1 -0
  57. package/dist/_virtual/qrcode.js +6 -0
  58. package/dist/_virtual/qrcode.js.map +1 -0
  59. package/dist/_virtual/regex.js +6 -0
  60. package/dist/_virtual/regex.js.map +1 -0
  61. package/dist/_virtual/segments.js +6 -0
  62. package/dist/_virtual/segments.js.map +1 -0
  63. package/dist/_virtual/server.js +6 -0
  64. package/dist/_virtual/server.js.map +1 -0
  65. package/dist/_virtual/svg-tag.js +6 -0
  66. package/dist/_virtual/svg-tag.js.map +1 -0
  67. package/dist/_virtual/svg.js +6 -0
  68. package/dist/_virtual/svg.js.map +1 -0
  69. package/dist/_virtual/sync-inflate.js +6 -0
  70. package/dist/_virtual/sync-inflate.js.map +1 -0
  71. package/dist/_virtual/sync-reader.js +6 -0
  72. package/dist/_virtual/sync-reader.js.map +1 -0
  73. package/dist/_virtual/terminal-small.js +6 -0
  74. package/dist/_virtual/terminal-small.js.map +1 -0
  75. package/dist/_virtual/terminal.js +6 -0
  76. package/dist/_virtual/terminal.js.map +1 -0
  77. package/dist/_virtual/terminal2.js +6 -0
  78. package/dist/_virtual/terminal2.js.map +1 -0
  79. package/dist/_virtual/utf8.js +6 -0
  80. package/dist/_virtual/utf8.js.map +1 -0
  81. package/dist/_virtual/utils.js +6 -0
  82. package/dist/_virtual/utils.js.map +1 -0
  83. package/dist/_virtual/utils2.js +6 -0
  84. package/dist/_virtual/utils2.js.map +1 -0
  85. package/dist/_virtual/version-check.js +6 -0
  86. package/dist/_virtual/version-check.js.map +1 -0
  87. package/dist/_virtual/version.js +6 -0
  88. package/dist/_virtual/version.js.map +1 -0
  89. package/dist/node_modules/dijkstrajs/dijkstra.js +179 -0
  90. package/dist/node_modules/dijkstrajs/dijkstra.js.map +1 -0
  91. package/dist/node_modules/pngjs/lib/bitmapper.js +281 -0
  92. package/dist/node_modules/pngjs/lib/bitmapper.js.map +1 -0
  93. package/dist/node_modules/pngjs/lib/bitpacker.js +172 -0
  94. package/dist/node_modules/pngjs/lib/bitpacker.js.map +1 -0
  95. package/dist/node_modules/pngjs/lib/chunkstream.js +204 -0
  96. package/dist/node_modules/pngjs/lib/chunkstream.js.map +1 -0
  97. package/dist/node_modules/pngjs/lib/constants.js +44 -0
  98. package/dist/node_modules/pngjs/lib/constants.js.map +1 -0
  99. package/dist/node_modules/pngjs/lib/crc.js +53 -0
  100. package/dist/node_modules/pngjs/lib/crc.js.map +1 -0
  101. package/dist/node_modules/pngjs/lib/filter-pack.js +185 -0
  102. package/dist/node_modules/pngjs/lib/filter-pack.js.map +1 -0
  103. package/dist/node_modules/pngjs/lib/filter-parse-async.js +40 -0
  104. package/dist/node_modules/pngjs/lib/filter-parse-async.js.map +1 -0
  105. package/dist/node_modules/pngjs/lib/filter-parse-sync.js +36 -0
  106. package/dist/node_modules/pngjs/lib/filter-parse-sync.js.map +1 -0
  107. package/dist/node_modules/pngjs/lib/filter-parse.js +192 -0
  108. package/dist/node_modules/pngjs/lib/filter-parse.js.map +1 -0
  109. package/dist/node_modules/pngjs/lib/format-normaliser.js +105 -0
  110. package/dist/node_modules/pngjs/lib/format-normaliser.js.map +1 -0
  111. package/dist/node_modules/pngjs/lib/interlace.js +108 -0
  112. package/dist/node_modules/pngjs/lib/interlace.js.map +1 -0
  113. package/dist/node_modules/pngjs/lib/packer-async.js +67 -0
  114. package/dist/node_modules/pngjs/lib/packer-async.js.map +1 -0
  115. package/dist/node_modules/pngjs/lib/packer-sync.js +72 -0
  116. package/dist/node_modules/pngjs/lib/packer-sync.js.map +1 -0
  117. package/dist/node_modules/pngjs/lib/packer.js +147 -0
  118. package/dist/node_modules/pngjs/lib/packer.js.map +1 -0
  119. package/dist/node_modules/pngjs/lib/paeth-predictor.js +28 -0
  120. package/dist/node_modules/pngjs/lib/paeth-predictor.js.map +1 -0
  121. package/dist/node_modules/pngjs/lib/parser-async.js +185 -0
  122. package/dist/node_modules/pngjs/lib/parser-async.js.map +1 -0
  123. package/dist/node_modules/pngjs/lib/parser-sync.js +128 -0
  124. package/dist/node_modules/pngjs/lib/parser-sync.js.map +1 -0
  125. package/dist/node_modules/pngjs/lib/parser.js +305 -0
  126. package/dist/node_modules/pngjs/lib/parser.js.map +1 -0
  127. package/dist/node_modules/pngjs/lib/png-sync.js +27 -0
  128. package/dist/node_modules/pngjs/lib/png-sync.js.map +1 -0
  129. package/dist/node_modules/pngjs/lib/png.js +212 -0
  130. package/dist/node_modules/pngjs/lib/png.js.map +1 -0
  131. package/dist/node_modules/pngjs/lib/sync-inflate.js +184 -0
  132. package/dist/node_modules/pngjs/lib/sync-inflate.js.map +1 -0
  133. package/dist/node_modules/pngjs/lib/sync-reader.js +58 -0
  134. package/dist/node_modules/pngjs/lib/sync-reader.js.map +1 -0
  135. package/dist/node_modules/qrcode/lib/browser.js +93 -0
  136. package/dist/node_modules/qrcode/lib/browser.js.map +1 -0
  137. package/dist/node_modules/qrcode/lib/can-promise.js +20 -0
  138. package/dist/node_modules/qrcode/lib/can-promise.js.map +1 -0
  139. package/dist/node_modules/qrcode/lib/core/alignment-pattern.js +100 -0
  140. package/dist/node_modules/qrcode/lib/core/alignment-pattern.js.map +1 -0
  141. package/dist/node_modules/qrcode/lib/core/alphanumeric-data.js +74 -0
  142. package/dist/node_modules/qrcode/lib/core/alphanumeric-data.js.map +1 -0
  143. package/dist/node_modules/qrcode/lib/core/bit-buffer.js +50 -0
  144. package/dist/node_modules/qrcode/lib/core/bit-buffer.js.map +1 -0
  145. package/dist/node_modules/qrcode/lib/core/bit-matrix.js +79 -0
  146. package/dist/node_modules/qrcode/lib/core/bit-matrix.js.map +1 -0
  147. package/dist/node_modules/qrcode/lib/core/byte-data.js +45 -0
  148. package/dist/node_modules/qrcode/lib/core/byte-data.js.map +1 -0
  149. package/dist/node_modules/qrcode/lib/core/error-correction-code.js +150 -0
  150. package/dist/node_modules/qrcode/lib/core/error-correction-code.js.map +1 -0
  151. package/dist/node_modules/qrcode/lib/core/error-correction-level.js +66 -0
  152. package/dist/node_modules/qrcode/lib/core/error-correction-level.js.map +1 -0
  153. package/dist/node_modules/qrcode/lib/core/finder-pattern.js +37 -0
  154. package/dist/node_modules/qrcode/lib/core/finder-pattern.js.map +1 -0
  155. package/dist/node_modules/qrcode/lib/core/format-info.js +44 -0
  156. package/dist/node_modules/qrcode/lib/core/format-info.js.map +1 -0
  157. package/dist/node_modules/qrcode/lib/core/galois-field.js +83 -0
  158. package/dist/node_modules/qrcode/lib/core/galois-field.js.map +1 -0
  159. package/dist/node_modules/qrcode/lib/core/kanji-data.js +70 -0
  160. package/dist/node_modules/qrcode/lib/core/kanji-data.js.map +1 -0
  161. package/dist/node_modules/qrcode/lib/core/mask-pattern.js +251 -0
  162. package/dist/node_modules/qrcode/lib/core/mask-pattern.js.map +1 -0
  163. package/dist/node_modules/qrcode/lib/core/mode.js +185 -0
  164. package/dist/node_modules/qrcode/lib/core/mode.js.map +1 -0
  165. package/dist/node_modules/qrcode/lib/core/numeric-data.js +58 -0
  166. package/dist/node_modules/qrcode/lib/core/numeric-data.js.map +1 -0
  167. package/dist/node_modules/qrcode/lib/core/polynomial.js +79 -0
  168. package/dist/node_modules/qrcode/lib/core/polynomial.js.map +1 -0
  169. package/dist/node_modules/qrcode/lib/core/qrcode.js +522 -0
  170. package/dist/node_modules/qrcode/lib/core/qrcode.js.map +1 -0
  171. package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.js +71 -0
  172. package/dist/node_modules/qrcode/lib/core/reed-solomon-encoder.js.map +1 -0
  173. package/dist/node_modules/qrcode/lib/core/regex.js +45 -0
  174. package/dist/node_modules/qrcode/lib/core/regex.js.map +1 -0
  175. package/dist/node_modules/qrcode/lib/core/segments.js +354 -0
  176. package/dist/node_modules/qrcode/lib/core/segments.js.map +1 -0
  177. package/dist/node_modules/qrcode/lib/core/utils.js +77 -0
  178. package/dist/node_modules/qrcode/lib/core/utils.js.map +1 -0
  179. package/dist/node_modules/qrcode/lib/core/version-check.js +24 -0
  180. package/dist/node_modules/qrcode/lib/core/version-check.js.map +1 -0
  181. package/dist/node_modules/qrcode/lib/core/version.js +184 -0
  182. package/dist/node_modules/qrcode/lib/core/version.js.map +1 -0
  183. package/dist/node_modules/qrcode/lib/index.js +27 -0
  184. package/dist/node_modules/qrcode/lib/index.js.map +1 -0
  185. package/dist/node_modules/qrcode/lib/renderer/canvas.js +80 -0
  186. package/dist/node_modules/qrcode/lib/renderer/canvas.js.map +1 -0
  187. package/dist/node_modules/qrcode/lib/renderer/png.js +97 -0
  188. package/dist/node_modules/qrcode/lib/renderer/png.js.map +1 -0
  189. package/dist/node_modules/qrcode/lib/renderer/svg-tag.js +96 -0
  190. package/dist/node_modules/qrcode/lib/renderer/svg-tag.js.map +1 -0
  191. package/dist/node_modules/qrcode/lib/renderer/svg.js +37 -0
  192. package/dist/node_modules/qrcode/lib/renderer/svg.js.map +1 -0
  193. package/dist/node_modules/qrcode/lib/renderer/terminal/terminal-small.js +99 -0
  194. package/dist/node_modules/qrcode/lib/renderer/terminal/terminal-small.js.map +1 -0
  195. package/dist/node_modules/qrcode/lib/renderer/terminal/terminal.js +63 -0
  196. package/dist/node_modules/qrcode/lib/renderer/terminal/terminal.js.map +1 -0
  197. package/dist/node_modules/qrcode/lib/renderer/terminal.js +25 -0
  198. package/dist/node_modules/qrcode/lib/renderer/terminal.js.map +1 -0
  199. package/dist/node_modules/qrcode/lib/renderer/utf8.js +89 -0
  200. package/dist/node_modules/qrcode/lib/renderer/utf8.js.map +1 -0
  201. package/dist/node_modules/qrcode/lib/renderer/utils.js +115 -0
  202. package/dist/node_modules/qrcode/lib/renderer/utils.js.map +1 -0
  203. package/dist/node_modules/qrcode/lib/server.js +159 -0
  204. package/dist/node_modules/qrcode/lib/server.js.map +1 -0
  205. package/dist/package.json.js +3 -2
  206. package/dist/package.json.js.map +1 -1
  207. package/dist/utils/qrcode.d.ts.map +1 -1
  208. package/dist/utils/qrcode.js +20 -10
  209. package/dist/utils/qrcode.js.map +1 -1
  210. package/package.json +3 -2
@@ -0,0 +1,179 @@
1
+ 'use strict';
2
+
3
+ var dijkstra = require('../../_virtual/dijkstra.js');
4
+
5
+ var hasRequiredDijkstra;
6
+
7
+ function requireDijkstra () {
8
+ if (hasRequiredDijkstra) return dijkstra.__module.exports;
9
+ hasRequiredDijkstra = 1;
10
+ (function (module) {
11
+
12
+ /******************************************************************************
13
+ * Created 2008-08-19.
14
+ *
15
+ * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.
16
+ *
17
+ * Copyright (C) 2008
18
+ * Wyatt Baldwin <self@wyattbaldwin.com>
19
+ * All rights reserved
20
+ *
21
+ * Licensed under the MIT license.
22
+ *
23
+ * http://www.opensource.org/licenses/mit-license.php
24
+ *
25
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
28
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
29
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
30
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
31
+ * THE SOFTWARE.
32
+ *****************************************************************************/
33
+ var dijkstra = {
34
+ single_source_shortest_paths: function(graph, s, d) {
35
+ // Predecessor map for each node that has been encountered.
36
+ // node ID => predecessor node ID
37
+ var predecessors = {};
38
+
39
+ // Costs of shortest paths from s to all nodes encountered.
40
+ // node ID => cost
41
+ var costs = {};
42
+ costs[s] = 0;
43
+
44
+ // Costs of shortest paths from s to all nodes encountered; differs from
45
+ // `costs` in that it provides easy access to the node that currently has
46
+ // the known shortest path from s.
47
+ // XXX: Do we actually need both `costs` and `open`?
48
+ var open = dijkstra.PriorityQueue.make();
49
+ open.push(s, 0);
50
+
51
+ var closest,
52
+ u, v,
53
+ cost_of_s_to_u,
54
+ adjacent_nodes,
55
+ cost_of_e,
56
+ cost_of_s_to_u_plus_cost_of_e,
57
+ cost_of_s_to_v,
58
+ first_visit;
59
+ while (!open.empty()) {
60
+ // In the nodes remaining in graph that have a known cost from s,
61
+ // find the node, u, that currently has the shortest path from s.
62
+ closest = open.pop();
63
+ u = closest.value;
64
+ cost_of_s_to_u = closest.cost;
65
+
66
+ // Get nodes adjacent to u...
67
+ adjacent_nodes = graph[u] || {};
68
+
69
+ // ...and explore the edges that connect u to those nodes, updating
70
+ // the cost of the shortest paths to any or all of those nodes as
71
+ // necessary. v is the node across the current edge from u.
72
+ for (v in adjacent_nodes) {
73
+ if (adjacent_nodes.hasOwnProperty(v)) {
74
+ // Get the cost of the edge running from u to v.
75
+ cost_of_e = adjacent_nodes[v];
76
+
77
+ // Cost of s to u plus the cost of u to v across e--this is *a*
78
+ // cost from s to v that may or may not be less than the current
79
+ // known cost to v.
80
+ cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;
81
+
82
+ // If we haven't visited v yet OR if the current known cost from s to
83
+ // v is greater than the new cost we just found (cost of s to u plus
84
+ // cost of u to v across e), update v's cost in the cost list and
85
+ // update v's predecessor in the predecessor list (it's now u).
86
+ cost_of_s_to_v = costs[v];
87
+ first_visit = (typeof costs[v] === 'undefined');
88
+ if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {
89
+ costs[v] = cost_of_s_to_u_plus_cost_of_e;
90
+ open.push(v, cost_of_s_to_u_plus_cost_of_e);
91
+ predecessors[v] = u;
92
+ }
93
+ }
94
+ }
95
+ }
96
+
97
+ if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {
98
+ var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');
99
+ throw new Error(msg);
100
+ }
101
+
102
+ return predecessors;
103
+ },
104
+
105
+ extract_shortest_path_from_predecessor_list: function(predecessors, d) {
106
+ var nodes = [];
107
+ var u = d;
108
+ while (u) {
109
+ nodes.push(u);
110
+ predecessors[u];
111
+ u = predecessors[u];
112
+ }
113
+ nodes.reverse();
114
+ return nodes;
115
+ },
116
+
117
+ find_path: function(graph, s, d) {
118
+ var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);
119
+ return dijkstra.extract_shortest_path_from_predecessor_list(
120
+ predecessors, d);
121
+ },
122
+
123
+ /**
124
+ * A very naive priority queue implementation.
125
+ */
126
+ PriorityQueue: {
127
+ make: function (opts) {
128
+ var T = dijkstra.PriorityQueue,
129
+ t = {},
130
+ key;
131
+ opts = opts || {};
132
+ for (key in T) {
133
+ if (T.hasOwnProperty(key)) {
134
+ t[key] = T[key];
135
+ }
136
+ }
137
+ t.queue = [];
138
+ t.sorter = opts.sorter || T.default_sorter;
139
+ return t;
140
+ },
141
+
142
+ default_sorter: function (a, b) {
143
+ return a.cost - b.cost;
144
+ },
145
+
146
+ /**
147
+ * Add a new item to the queue and ensure the highest priority element
148
+ * is at the front of the queue.
149
+ */
150
+ push: function (value, cost) {
151
+ var item = {value: value, cost: cost};
152
+ this.queue.push(item);
153
+ this.queue.sort(this.sorter);
154
+ },
155
+
156
+ /**
157
+ * Return the highest priority element in the queue.
158
+ */
159
+ pop: function () {
160
+ return this.queue.shift();
161
+ },
162
+
163
+ empty: function () {
164
+ return this.queue.length === 0;
165
+ }
166
+ }
167
+ };
168
+
169
+
170
+ // node.js module exports
171
+ {
172
+ module.exports = dijkstra;
173
+ }
174
+ } (dijkstra.__module));
175
+ return dijkstra.__module.exports;
176
+ }
177
+
178
+ exports.__require = requireDijkstra;
179
+ //# sourceMappingURL=dijkstra.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dijkstra.js","sources":["../../../node_modules/dijkstrajs/dijkstra.js"],"sourcesContent":["'use strict';\n\n/******************************************************************************\n * Created 2008-08-19.\n *\n * Dijkstra path-finding functions. Adapted from the Dijkstar Python project.\n *\n * Copyright (C) 2008\n * Wyatt Baldwin <self@wyattbaldwin.com>\n * All rights reserved\n *\n * Licensed under the MIT license.\n *\n * http://www.opensource.org/licenses/mit-license.php\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN\n * THE SOFTWARE.\n *****************************************************************************/\nvar dijkstra = {\n single_source_shortest_paths: function(graph, s, d) {\n // Predecessor map for each node that has been encountered.\n // node ID => predecessor node ID\n var predecessors = {};\n\n // Costs of shortest paths from s to all nodes encountered.\n // node ID => cost\n var costs = {};\n costs[s] = 0;\n\n // Costs of shortest paths from s to all nodes encountered; differs from\n // `costs` in that it provides easy access to the node that currently has\n // the known shortest path from s.\n // XXX: Do we actually need both `costs` and `open`?\n var open = dijkstra.PriorityQueue.make();\n open.push(s, 0);\n\n var closest,\n u, v,\n cost_of_s_to_u,\n adjacent_nodes,\n cost_of_e,\n cost_of_s_to_u_plus_cost_of_e,\n cost_of_s_to_v,\n first_visit;\n while (!open.empty()) {\n // In the nodes remaining in graph that have a known cost from s,\n // find the node, u, that currently has the shortest path from s.\n closest = open.pop();\n u = closest.value;\n cost_of_s_to_u = closest.cost;\n\n // Get nodes adjacent to u...\n adjacent_nodes = graph[u] || {};\n\n // ...and explore the edges that connect u to those nodes, updating\n // the cost of the shortest paths to any or all of those nodes as\n // necessary. v is the node across the current edge from u.\n for (v in adjacent_nodes) {\n if (adjacent_nodes.hasOwnProperty(v)) {\n // Get the cost of the edge running from u to v.\n cost_of_e = adjacent_nodes[v];\n\n // Cost of s to u plus the cost of u to v across e--this is *a*\n // cost from s to v that may or may not be less than the current\n // known cost to v.\n cost_of_s_to_u_plus_cost_of_e = cost_of_s_to_u + cost_of_e;\n\n // If we haven't visited v yet OR if the current known cost from s to\n // v is greater than the new cost we just found (cost of s to u plus\n // cost of u to v across e), update v's cost in the cost list and\n // update v's predecessor in the predecessor list (it's now u).\n cost_of_s_to_v = costs[v];\n first_visit = (typeof costs[v] === 'undefined');\n if (first_visit || cost_of_s_to_v > cost_of_s_to_u_plus_cost_of_e) {\n costs[v] = cost_of_s_to_u_plus_cost_of_e;\n open.push(v, cost_of_s_to_u_plus_cost_of_e);\n predecessors[v] = u;\n }\n }\n }\n }\n\n if (typeof d !== 'undefined' && typeof costs[d] === 'undefined') {\n var msg = ['Could not find a path from ', s, ' to ', d, '.'].join('');\n throw new Error(msg);\n }\n\n return predecessors;\n },\n\n extract_shortest_path_from_predecessor_list: function(predecessors, d) {\n var nodes = [];\n var u = d;\n var predecessor;\n while (u) {\n nodes.push(u);\n predecessor = predecessors[u];\n u = predecessors[u];\n }\n nodes.reverse();\n return nodes;\n },\n\n find_path: function(graph, s, d) {\n var predecessors = dijkstra.single_source_shortest_paths(graph, s, d);\n return dijkstra.extract_shortest_path_from_predecessor_list(\n predecessors, d);\n },\n\n /**\n * A very naive priority queue implementation.\n */\n PriorityQueue: {\n make: function (opts) {\n var T = dijkstra.PriorityQueue,\n t = {},\n key;\n opts = opts || {};\n for (key in T) {\n if (T.hasOwnProperty(key)) {\n t[key] = T[key];\n }\n }\n t.queue = [];\n t.sorter = opts.sorter || T.default_sorter;\n return t;\n },\n\n default_sorter: function (a, b) {\n return a.cost - b.cost;\n },\n\n /**\n * Add a new item to the queue and ensure the highest priority element\n * is at the front of the queue.\n */\n push: function (value, cost) {\n var item = {value: value, cost: cost};\n this.queue.push(item);\n this.queue.sort(this.sorter);\n },\n\n /**\n * Return the highest priority element in the queue.\n */\n pop: function () {\n return this.queue.shift();\n },\n\n empty: function () {\n return this.queue.length === 0;\n }\n }\n};\n\n\n// node.js module exports\nif (typeof module !== 'undefined') {\n module.exports = dijkstra;\n}\n"],"names":[],"mappings":";;;;;;;;;;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,EAAA,IAAI,QAAQ,GAAG;IACb,4BAA4B,EAAE,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE;AACtD;AACA;MACI,IAAI,YAAY,GAAG,EAAE;;AAEzB;AACA;MACI,IAAI,KAAK,GAAG,EAAE;AAClB,MAAI,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC;;AAEhB;AACA;AACA;AACA;MACI,IAAI,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,IAAI,EAAE;AAC5C,MAAI,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC,CAAC;;AAEnB,MAAI,IAAI,OAAO;UACP,CAAC,EAAE,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CAAC;MACd,CAAK;;AAEL,MAAI,cAAc,EAAE,UAAU,CAAC,EAAE,CAAC,EAAE;AACpC,QAAM,OAAO,CAAC,CAAC,IAAI,GAAG,CAAC,CAAC,IAAI;MAC5B,CAAK;;AAEL;AACA;AACA;AACA;AACA,MAAI,IAAI,EAAE,UAAU,KAAK,EAAE,IAAI,EAAE;QAC3B,IAAI,IAAI,GAAG,CAAC,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,CAAC;AAC3C,QAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC;MAClC,CAAK;;AAEL;AACA;AACA;MACI,GAAG,EAAE,YAAY;AACrB,QAAM,OAAO,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE;MAC/B,CAAK;;MAED,KAAK,EAAE,YAAY;AACvB,QAAM,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,KAAK,CAAC;AACpC,MAAA;AACA;GACC;;;AAGD;EACmC;AACnC,IAAE,iBAAiB,QAAQ;AAC3B,EAAA,CAAA;;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,281 @@
1
+ 'use strict';
2
+
3
+ var bitmapper = require('../../../_virtual/bitmapper.js');
4
+ var interlace = require('./interlace.js');
5
+
6
+ var hasRequiredBitmapper;
7
+
8
+ function requireBitmapper () {
9
+ if (hasRequiredBitmapper) return bitmapper.__exports;
10
+ hasRequiredBitmapper = 1;
11
+
12
+ let interlaceUtils = interlace.__require();
13
+
14
+ let pixelBppMapper = [
15
+ // 0 - dummy entry
16
+ function () {},
17
+
18
+ // 1 - L
19
+ // 0: 0, 1: 0, 2: 0, 3: 0xff
20
+ function (pxData, data, pxPos, rawPos) {
21
+ if (rawPos === data.length) {
22
+ throw new Error("Ran out of data");
23
+ }
24
+
25
+ let pixel = data[rawPos];
26
+ pxData[pxPos] = pixel;
27
+ pxData[pxPos + 1] = pixel;
28
+ pxData[pxPos + 2] = pixel;
29
+ pxData[pxPos + 3] = 0xff;
30
+ },
31
+
32
+ // 2 - LA
33
+ // 0: 0, 1: 0, 2: 0, 3: 1
34
+ function (pxData, data, pxPos, rawPos) {
35
+ if (rawPos + 1 >= data.length) {
36
+ throw new Error("Ran out of data");
37
+ }
38
+
39
+ let pixel = data[rawPos];
40
+ pxData[pxPos] = pixel;
41
+ pxData[pxPos + 1] = pixel;
42
+ pxData[pxPos + 2] = pixel;
43
+ pxData[pxPos + 3] = data[rawPos + 1];
44
+ },
45
+
46
+ // 3 - RGB
47
+ // 0: 0, 1: 1, 2: 2, 3: 0xff
48
+ function (pxData, data, pxPos, rawPos) {
49
+ if (rawPos + 2 >= data.length) {
50
+ throw new Error("Ran out of data");
51
+ }
52
+
53
+ pxData[pxPos] = data[rawPos];
54
+ pxData[pxPos + 1] = data[rawPos + 1];
55
+ pxData[pxPos + 2] = data[rawPos + 2];
56
+ pxData[pxPos + 3] = 0xff;
57
+ },
58
+
59
+ // 4 - RGBA
60
+ // 0: 0, 1: 1, 2: 2, 3: 3
61
+ function (pxData, data, pxPos, rawPos) {
62
+ if (rawPos + 3 >= data.length) {
63
+ throw new Error("Ran out of data");
64
+ }
65
+
66
+ pxData[pxPos] = data[rawPos];
67
+ pxData[pxPos + 1] = data[rawPos + 1];
68
+ pxData[pxPos + 2] = data[rawPos + 2];
69
+ pxData[pxPos + 3] = data[rawPos + 3];
70
+ },
71
+ ];
72
+
73
+ let pixelBppCustomMapper = [
74
+ // 0 - dummy entry
75
+ function () {},
76
+
77
+ // 1 - L
78
+ // 0: 0, 1: 0, 2: 0, 3: 0xff
79
+ function (pxData, pixelData, pxPos, maxBit) {
80
+ let pixel = pixelData[0];
81
+ pxData[pxPos] = pixel;
82
+ pxData[pxPos + 1] = pixel;
83
+ pxData[pxPos + 2] = pixel;
84
+ pxData[pxPos + 3] = maxBit;
85
+ },
86
+
87
+ // 2 - LA
88
+ // 0: 0, 1: 0, 2: 0, 3: 1
89
+ function (pxData, pixelData, pxPos) {
90
+ let pixel = pixelData[0];
91
+ pxData[pxPos] = pixel;
92
+ pxData[pxPos + 1] = pixel;
93
+ pxData[pxPos + 2] = pixel;
94
+ pxData[pxPos + 3] = pixelData[1];
95
+ },
96
+
97
+ // 3 - RGB
98
+ // 0: 0, 1: 1, 2: 2, 3: 0xff
99
+ function (pxData, pixelData, pxPos, maxBit) {
100
+ pxData[pxPos] = pixelData[0];
101
+ pxData[pxPos + 1] = pixelData[1];
102
+ pxData[pxPos + 2] = pixelData[2];
103
+ pxData[pxPos + 3] = maxBit;
104
+ },
105
+
106
+ // 4 - RGBA
107
+ // 0: 0, 1: 1, 2: 2, 3: 3
108
+ function (pxData, pixelData, pxPos) {
109
+ pxData[pxPos] = pixelData[0];
110
+ pxData[pxPos + 1] = pixelData[1];
111
+ pxData[pxPos + 2] = pixelData[2];
112
+ pxData[pxPos + 3] = pixelData[3];
113
+ },
114
+ ];
115
+
116
+ function bitRetriever(data, depth) {
117
+ let leftOver = [];
118
+ let i = 0;
119
+
120
+ function split() {
121
+ if (i === data.length) {
122
+ throw new Error("Ran out of data");
123
+ }
124
+ let byte = data[i];
125
+ i++;
126
+ let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;
127
+ switch (depth) {
128
+ default:
129
+ throw new Error("unrecognised depth");
130
+ case 16:
131
+ byte2 = data[i];
132
+ i++;
133
+ leftOver.push((byte << 8) + byte2);
134
+ break;
135
+ case 4:
136
+ byte2 = byte & 0x0f;
137
+ byte1 = byte >> 4;
138
+ leftOver.push(byte1, byte2);
139
+ break;
140
+ case 2:
141
+ byte4 = byte & 3;
142
+ byte3 = (byte >> 2) & 3;
143
+ byte2 = (byte >> 4) & 3;
144
+ byte1 = (byte >> 6) & 3;
145
+ leftOver.push(byte1, byte2, byte3, byte4);
146
+ break;
147
+ case 1:
148
+ byte8 = byte & 1;
149
+ byte7 = (byte >> 1) & 1;
150
+ byte6 = (byte >> 2) & 1;
151
+ byte5 = (byte >> 3) & 1;
152
+ byte4 = (byte >> 4) & 1;
153
+ byte3 = (byte >> 5) & 1;
154
+ byte2 = (byte >> 6) & 1;
155
+ byte1 = (byte >> 7) & 1;
156
+ leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8);
157
+ break;
158
+ }
159
+ }
160
+
161
+ return {
162
+ get: function (count) {
163
+ while (leftOver.length < count) {
164
+ split();
165
+ }
166
+ let returner = leftOver.slice(0, count);
167
+ leftOver = leftOver.slice(count);
168
+ return returner;
169
+ },
170
+ resetAfterLine: function () {
171
+ leftOver.length = 0;
172
+ },
173
+ end: function () {
174
+ if (i !== data.length) {
175
+ throw new Error("extra data found");
176
+ }
177
+ },
178
+ };
179
+ }
180
+
181
+ function mapImage8Bit(image, pxData, getPxPos, bpp, data, rawPos) {
182
+ // eslint-disable-line max-params
183
+ let imageWidth = image.width;
184
+ let imageHeight = image.height;
185
+ let imagePass = image.index;
186
+ for (let y = 0; y < imageHeight; y++) {
187
+ for (let x = 0; x < imageWidth; x++) {
188
+ let pxPos = getPxPos(x, y, imagePass);
189
+ pixelBppMapper[bpp](pxData, data, pxPos, rawPos);
190
+ rawPos += bpp; //eslint-disable-line no-param-reassign
191
+ }
192
+ }
193
+ return rawPos;
194
+ }
195
+
196
+ function mapImageCustomBit(image, pxData, getPxPos, bpp, bits, maxBit) {
197
+ // eslint-disable-line max-params
198
+ let imageWidth = image.width;
199
+ let imageHeight = image.height;
200
+ let imagePass = image.index;
201
+ for (let y = 0; y < imageHeight; y++) {
202
+ for (let x = 0; x < imageWidth; x++) {
203
+ let pixelData = bits.get(bpp);
204
+ let pxPos = getPxPos(x, y, imagePass);
205
+ pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit);
206
+ }
207
+ bits.resetAfterLine();
208
+ }
209
+ }
210
+
211
+ bitmapper.__exports.dataToBitMap = function (data, bitmapInfo) {
212
+ let width = bitmapInfo.width;
213
+ let height = bitmapInfo.height;
214
+ let depth = bitmapInfo.depth;
215
+ let bpp = bitmapInfo.bpp;
216
+ let interlace = bitmapInfo.interlace;
217
+ let bits;
218
+
219
+ if (depth !== 8) {
220
+ bits = bitRetriever(data, depth);
221
+ }
222
+ let pxData;
223
+ if (depth <= 8) {
224
+ pxData = Buffer.alloc(width * height * 4);
225
+ } else {
226
+ pxData = new Uint16Array(width * height * 4);
227
+ }
228
+ let maxBit = Math.pow(2, depth) - 1;
229
+ let rawPos = 0;
230
+ let images;
231
+ let getPxPos;
232
+
233
+ if (interlace) {
234
+ images = interlaceUtils.getImagePasses(width, height);
235
+ getPxPos = interlaceUtils.getInterlaceIterator(width, height);
236
+ } else {
237
+ let nonInterlacedPxPos = 0;
238
+ getPxPos = function () {
239
+ let returner = nonInterlacedPxPos;
240
+ nonInterlacedPxPos += 4;
241
+ return returner;
242
+ };
243
+ images = [{ width: width, height: height }];
244
+ }
245
+
246
+ for (let imageIndex = 0; imageIndex < images.length; imageIndex++) {
247
+ if (depth === 8) {
248
+ rawPos = mapImage8Bit(
249
+ images[imageIndex],
250
+ pxData,
251
+ getPxPos,
252
+ bpp,
253
+ data,
254
+ rawPos
255
+ );
256
+ } else {
257
+ mapImageCustomBit(
258
+ images[imageIndex],
259
+ pxData,
260
+ getPxPos,
261
+ bpp,
262
+ bits,
263
+ maxBit
264
+ );
265
+ }
266
+ }
267
+ if (depth === 8) {
268
+ if (rawPos !== data.length) {
269
+ throw new Error("extra data found");
270
+ }
271
+ } else {
272
+ bits.end();
273
+ }
274
+
275
+ return pxData;
276
+ };
277
+ return bitmapper.__exports;
278
+ }
279
+
280
+ exports.__require = requireBitmapper;
281
+ //# sourceMappingURL=bitmapper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bitmapper.js","sources":["../../../../node_modules/pngjs/lib/bitmapper.js"],"sourcesContent":["\"use strict\";\n\nlet interlaceUtils = require(\"./interlace\");\n\nlet pixelBppMapper = [\n // 0 - dummy entry\n function () {},\n\n // 1 - L\n // 0: 0, 1: 0, 2: 0, 3: 0xff\n function (pxData, data, pxPos, rawPos) {\n if (rawPos === data.length) {\n throw new Error(\"Ran out of data\");\n }\n\n let pixel = data[rawPos];\n pxData[pxPos] = pixel;\n pxData[pxPos + 1] = pixel;\n pxData[pxPos + 2] = pixel;\n pxData[pxPos + 3] = 0xff;\n },\n\n // 2 - LA\n // 0: 0, 1: 0, 2: 0, 3: 1\n function (pxData, data, pxPos, rawPos) {\n if (rawPos + 1 >= data.length) {\n throw new Error(\"Ran out of data\");\n }\n\n let pixel = data[rawPos];\n pxData[pxPos] = pixel;\n pxData[pxPos + 1] = pixel;\n pxData[pxPos + 2] = pixel;\n pxData[pxPos + 3] = data[rawPos + 1];\n },\n\n // 3 - RGB\n // 0: 0, 1: 1, 2: 2, 3: 0xff\n function (pxData, data, pxPos, rawPos) {\n if (rawPos + 2 >= data.length) {\n throw new Error(\"Ran out of data\");\n }\n\n pxData[pxPos] = data[rawPos];\n pxData[pxPos + 1] = data[rawPos + 1];\n pxData[pxPos + 2] = data[rawPos + 2];\n pxData[pxPos + 3] = 0xff;\n },\n\n // 4 - RGBA\n // 0: 0, 1: 1, 2: 2, 3: 3\n function (pxData, data, pxPos, rawPos) {\n if (rawPos + 3 >= data.length) {\n throw new Error(\"Ran out of data\");\n }\n\n pxData[pxPos] = data[rawPos];\n pxData[pxPos + 1] = data[rawPos + 1];\n pxData[pxPos + 2] = data[rawPos + 2];\n pxData[pxPos + 3] = data[rawPos + 3];\n },\n];\n\nlet pixelBppCustomMapper = [\n // 0 - dummy entry\n function () {},\n\n // 1 - L\n // 0: 0, 1: 0, 2: 0, 3: 0xff\n function (pxData, pixelData, pxPos, maxBit) {\n let pixel = pixelData[0];\n pxData[pxPos] = pixel;\n pxData[pxPos + 1] = pixel;\n pxData[pxPos + 2] = pixel;\n pxData[pxPos + 3] = maxBit;\n },\n\n // 2 - LA\n // 0: 0, 1: 0, 2: 0, 3: 1\n function (pxData, pixelData, pxPos) {\n let pixel = pixelData[0];\n pxData[pxPos] = pixel;\n pxData[pxPos + 1] = pixel;\n pxData[pxPos + 2] = pixel;\n pxData[pxPos + 3] = pixelData[1];\n },\n\n // 3 - RGB\n // 0: 0, 1: 1, 2: 2, 3: 0xff\n function (pxData, pixelData, pxPos, maxBit) {\n pxData[pxPos] = pixelData[0];\n pxData[pxPos + 1] = pixelData[1];\n pxData[pxPos + 2] = pixelData[2];\n pxData[pxPos + 3] = maxBit;\n },\n\n // 4 - RGBA\n // 0: 0, 1: 1, 2: 2, 3: 3\n function (pxData, pixelData, pxPos) {\n pxData[pxPos] = pixelData[0];\n pxData[pxPos + 1] = pixelData[1];\n pxData[pxPos + 2] = pixelData[2];\n pxData[pxPos + 3] = pixelData[3];\n },\n];\n\nfunction bitRetriever(data, depth) {\n let leftOver = [];\n let i = 0;\n\n function split() {\n if (i === data.length) {\n throw new Error(\"Ran out of data\");\n }\n let byte = data[i];\n i++;\n let byte8, byte7, byte6, byte5, byte4, byte3, byte2, byte1;\n switch (depth) {\n default:\n throw new Error(\"unrecognised depth\");\n case 16:\n byte2 = data[i];\n i++;\n leftOver.push((byte << 8) + byte2);\n break;\n case 4:\n byte2 = byte & 0x0f;\n byte1 = byte >> 4;\n leftOver.push(byte1, byte2);\n break;\n case 2:\n byte4 = byte & 3;\n byte3 = (byte >> 2) & 3;\n byte2 = (byte >> 4) & 3;\n byte1 = (byte >> 6) & 3;\n leftOver.push(byte1, byte2, byte3, byte4);\n break;\n case 1:\n byte8 = byte & 1;\n byte7 = (byte >> 1) & 1;\n byte6 = (byte >> 2) & 1;\n byte5 = (byte >> 3) & 1;\n byte4 = (byte >> 4) & 1;\n byte3 = (byte >> 5) & 1;\n byte2 = (byte >> 6) & 1;\n byte1 = (byte >> 7) & 1;\n leftOver.push(byte1, byte2, byte3, byte4, byte5, byte6, byte7, byte8);\n break;\n }\n }\n\n return {\n get: function (count) {\n while (leftOver.length < count) {\n split();\n }\n let returner = leftOver.slice(0, count);\n leftOver = leftOver.slice(count);\n return returner;\n },\n resetAfterLine: function () {\n leftOver.length = 0;\n },\n end: function () {\n if (i !== data.length) {\n throw new Error(\"extra data found\");\n }\n },\n };\n}\n\nfunction mapImage8Bit(image, pxData, getPxPos, bpp, data, rawPos) {\n // eslint-disable-line max-params\n let imageWidth = image.width;\n let imageHeight = image.height;\n let imagePass = image.index;\n for (let y = 0; y < imageHeight; y++) {\n for (let x = 0; x < imageWidth; x++) {\n let pxPos = getPxPos(x, y, imagePass);\n pixelBppMapper[bpp](pxData, data, pxPos, rawPos);\n rawPos += bpp; //eslint-disable-line no-param-reassign\n }\n }\n return rawPos;\n}\n\nfunction mapImageCustomBit(image, pxData, getPxPos, bpp, bits, maxBit) {\n // eslint-disable-line max-params\n let imageWidth = image.width;\n let imageHeight = image.height;\n let imagePass = image.index;\n for (let y = 0; y < imageHeight; y++) {\n for (let x = 0; x < imageWidth; x++) {\n let pixelData = bits.get(bpp);\n let pxPos = getPxPos(x, y, imagePass);\n pixelBppCustomMapper[bpp](pxData, pixelData, pxPos, maxBit);\n }\n bits.resetAfterLine();\n }\n}\n\nexports.dataToBitMap = function (data, bitmapInfo) {\n let width = bitmapInfo.width;\n let height = bitmapInfo.height;\n let depth = bitmapInfo.depth;\n let bpp = bitmapInfo.bpp;\n let interlace = bitmapInfo.interlace;\n let bits;\n\n if (depth !== 8) {\n bits = bitRetriever(data, depth);\n }\n let pxData;\n if (depth <= 8) {\n pxData = Buffer.alloc(width * height * 4);\n } else {\n pxData = new Uint16Array(width * height * 4);\n }\n let maxBit = Math.pow(2, depth) - 1;\n let rawPos = 0;\n let images;\n let getPxPos;\n\n if (interlace) {\n images = interlaceUtils.getImagePasses(width, height);\n getPxPos = interlaceUtils.getInterlaceIterator(width, height);\n } else {\n let nonInterlacedPxPos = 0;\n getPxPos = function () {\n let returner = nonInterlacedPxPos;\n nonInterlacedPxPos += 4;\n return returner;\n };\n images = [{ width: width, height: height }];\n }\n\n for (let imageIndex = 0; imageIndex < images.length; imageIndex++) {\n if (depth === 8) {\n rawPos = mapImage8Bit(\n images[imageIndex],\n pxData,\n getPxPos,\n bpp,\n data,\n rawPos\n );\n } else {\n mapImageCustomBit(\n images[imageIndex],\n pxData,\n getPxPos,\n bpp,\n bits,\n maxBit\n );\n }\n }\n if (depth === 8) {\n if (rawPos !== data.length) {\n throw new Error(\"extra data found\");\n }\n } else {\n bits.end();\n }\n\n return pxData;\n};\n"],"names":["require$$0","bitmapper"],"mappings":";;;;;;;;;;;CAEA,IAAI,cAAc,GAAGA,mBAAA,EAAsB;;AAE3C,CAAA,IAAI,cAAc,GAAG;AACrB;AACA,GAAE,YAAY,CAAA,CAAE;;AAEhB;AACA;GACE,UAAU,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;AACzC,KAAI,IAAI,MAAM,KAAK,IAAI,CAAC,MAAM,EAAE;AAChC,OAAM,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;AACxC,KAAA;;AAEA,KAAI,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;AAC5B,KAAI,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK;AACzB,KAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;AAC7B,KAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;AAC7B,KAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,IAAI;GAC5B,CAAG;;AAEH;AACA;GACE,UAAU,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAE;KACrC,IAAI,MAAM,GAAG,CAAC,IAAI,IAAI,CAAC,MAAM,EAAE;AACnC,OAAM,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC;AACxC,KAAA;;AAEA,KAAI,IAAI,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC;AAC5B,KAAI,MAAM,CAAC,KAAK,CAAC,GAAG,KAAK;AACzB,KAAI,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,GAAG,KAAK;AAC7B,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AE,OAAO,MAAM;CACf,CAAC;;;;;;","x_google_ignoreList":[0]}
@@ -0,0 +1,172 @@
1
+ 'use strict';
2
+
3
+ var constants = require('./constants.js');
4
+
5
+ var bitpacker;
6
+ var hasRequiredBitpacker;
7
+
8
+ function requireBitpacker () {
9
+ if (hasRequiredBitpacker) return bitpacker;
10
+ hasRequiredBitpacker = 1;
11
+
12
+ let constants$1 = constants.__require();
13
+
14
+ bitpacker = function (dataIn, width, height, options) {
15
+ let outHasAlpha =
16
+ [constants$1.COLORTYPE_COLOR_ALPHA, constants$1.COLORTYPE_ALPHA].indexOf(
17
+ options.colorType
18
+ ) !== -1;
19
+ if (options.colorType === options.inputColorType) {
20
+ let bigEndian = (function () {
21
+ let buffer = new ArrayBuffer(2);
22
+ new DataView(buffer).setInt16(0, 256, true /* littleEndian */);
23
+ // Int16Array uses the platform's endianness.
24
+ return new Int16Array(buffer)[0] !== 256;
25
+ })();
26
+ // If no need to convert to grayscale and alpha is present/absent in both, take a fast route
27
+ if (options.bitDepth === 8 || (options.bitDepth === 16 && bigEndian)) {
28
+ return dataIn;
29
+ }
30
+ }
31
+
32
+ // map to a UInt16 array if data is 16bit, fix endianness below
33
+ let data = options.bitDepth !== 16 ? dataIn : new Uint16Array(dataIn.buffer);
34
+
35
+ let maxValue = 255;
36
+ let inBpp = constants$1.COLORTYPE_TO_BPP_MAP[options.inputColorType];
37
+ if (inBpp === 4 && !options.inputHasAlpha) {
38
+ inBpp = 3;
39
+ }
40
+ let outBpp = constants$1.COLORTYPE_TO_BPP_MAP[options.colorType];
41
+ if (options.bitDepth === 16) {
42
+ maxValue = 65535;
43
+ outBpp *= 2;
44
+ }
45
+ let outData = Buffer.alloc(width * height * outBpp);
46
+
47
+ let inIndex = 0;
48
+ let outIndex = 0;
49
+
50
+ let bgColor = options.bgColor || {};
51
+ if (bgColor.red === undefined) {
52
+ bgColor.red = maxValue;
53
+ }
54
+ if (bgColor.green === undefined) {
55
+ bgColor.green = maxValue;
56
+ }
57
+ if (bgColor.blue === undefined) {
58
+ bgColor.blue = maxValue;
59
+ }
60
+
61
+ function getRGBA() {
62
+ let red;
63
+ let green;
64
+ let blue;
65
+ let alpha = maxValue;
66
+ switch (options.inputColorType) {
67
+ case constants$1.COLORTYPE_COLOR_ALPHA:
68
+ alpha = data[inIndex + 3];
69
+ red = data[inIndex];
70
+ green = data[inIndex + 1];
71
+ blue = data[inIndex + 2];
72
+ break;
73
+ case constants$1.COLORTYPE_COLOR:
74
+ red = data[inIndex];
75
+ green = data[inIndex + 1];
76
+ blue = data[inIndex + 2];
77
+ break;
78
+ case constants$1.COLORTYPE_ALPHA:
79
+ alpha = data[inIndex + 1];
80
+ red = data[inIndex];
81
+ green = red;
82
+ blue = red;
83
+ break;
84
+ case constants$1.COLORTYPE_GRAYSCALE:
85
+ red = data[inIndex];
86
+ green = red;
87
+ blue = red;
88
+ break;
89
+ default:
90
+ throw new Error(
91
+ "input color type:" +
92
+ options.inputColorType +
93
+ " is not supported at present"
94
+ );
95
+ }
96
+
97
+ if (options.inputHasAlpha) {
98
+ if (!outHasAlpha) {
99
+ alpha /= maxValue;
100
+ red = Math.min(
101
+ Math.max(Math.round((1 - alpha) * bgColor.red + alpha * red), 0),
102
+ maxValue
103
+ );
104
+ green = Math.min(
105
+ Math.max(Math.round((1 - alpha) * bgColor.green + alpha * green), 0),
106
+ maxValue
107
+ );
108
+ blue = Math.min(
109
+ Math.max(Math.round((1 - alpha) * bgColor.blue + alpha * blue), 0),
110
+ maxValue
111
+ );
112
+ }
113
+ }
114
+ return { red: red, green: green, blue: blue, alpha: alpha };
115
+ }
116
+
117
+ for (let y = 0; y < height; y++) {
118
+ for (let x = 0; x < width; x++) {
119
+ let rgba = getRGBA();
120
+
121
+ switch (options.colorType) {
122
+ case constants$1.COLORTYPE_COLOR_ALPHA:
123
+ case constants$1.COLORTYPE_COLOR:
124
+ if (options.bitDepth === 8) {
125
+ outData[outIndex] = rgba.red;
126
+ outData[outIndex + 1] = rgba.green;
127
+ outData[outIndex + 2] = rgba.blue;
128
+ if (outHasAlpha) {
129
+ outData[outIndex + 3] = rgba.alpha;
130
+ }
131
+ } else {
132
+ outData.writeUInt16BE(rgba.red, outIndex);
133
+ outData.writeUInt16BE(rgba.green, outIndex + 2);
134
+ outData.writeUInt16BE(rgba.blue, outIndex + 4);
135
+ if (outHasAlpha) {
136
+ outData.writeUInt16BE(rgba.alpha, outIndex + 6);
137
+ }
138
+ }
139
+ break;
140
+ case constants$1.COLORTYPE_ALPHA:
141
+ case constants$1.COLORTYPE_GRAYSCALE: {
142
+ // Convert to grayscale and alpha
143
+ let grayscale = (rgba.red + rgba.green + rgba.blue) / 3;
144
+ if (options.bitDepth === 8) {
145
+ outData[outIndex] = grayscale;
146
+ if (outHasAlpha) {
147
+ outData[outIndex + 1] = rgba.alpha;
148
+ }
149
+ } else {
150
+ outData.writeUInt16BE(grayscale, outIndex);
151
+ if (outHasAlpha) {
152
+ outData.writeUInt16BE(rgba.alpha, outIndex + 2);
153
+ }
154
+ }
155
+ break;
156
+ }
157
+ default:
158
+ throw new Error("unrecognised color Type " + options.colorType);
159
+ }
160
+
161
+ inIndex += inBpp;
162
+ outIndex += outBpp;
163
+ }
164
+ }
165
+
166
+ return outData;
167
+ };
168
+ return bitpacker;
169
+ }
170
+
171
+ exports.__require = requireBitpacker;
172
+ //# sourceMappingURL=bitpacker.js.map