@pittica/drive-folder-qrcode 1.3.1 → 1.3.2

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.
@@ -26,62 +26,110 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
26
26
  // See the License for the specific language governing permissions and
27
27
  // limitations under the License.
28
28
  var _default = exports["default"] = /*#__PURE__*/function () {
29
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(drive, output, logo, colors, font, size, margin) {
29
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(drive, output, logo, colors, font, size, margin) {
30
30
  var rounded,
31
31
  format,
32
32
  credentials,
33
- images,
34
- _args2 = arguments;
35
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
36
- while (1) switch (_context2.prev = _context2.next) {
33
+ _args5 = arguments;
34
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
35
+ while (1) switch (_context5.prev = _context5.next) {
37
36
  case 0:
38
- rounded = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : false;
39
- format = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : "PDF";
40
- credentials = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : null;
41
- _context2.next = 5;
42
- return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials);
37
+ rounded = _args5.length > 7 && _args5[7] !== undefined ? _args5[7] : false;
38
+ format = _args5.length > 8 && _args5[8] !== undefined ? _args5[8] : "PDF";
39
+ credentials = _args5.length > 9 && _args5[9] !== undefined ? _args5[9] : null;
40
+ _context5.next = 5;
41
+ return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials).then(/*#__PURE__*/function () {
42
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(images) {
43
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
44
+ while (1) switch (_context4.prev = _context4.next) {
45
+ case 0:
46
+ _context4.next = 2;
47
+ return Promise.all(images.map(/*#__PURE__*/function () {
48
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(_ref3) {
49
+ var _ref3$folder, id, name, qr;
50
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
51
+ while (1) switch (_context3.prev = _context3.next) {
52
+ case 0:
53
+ _ref3$folder = _ref3.folder, id = _ref3$folder.id, name = _ref3$folder.name, qr = _ref3.qr;
54
+ _context3.next = 3;
55
+ return qr.getRawData("svg").then(/*#__PURE__*/function () {
56
+ var _ref5 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(buffer) {
57
+ var doc, stream, s;
58
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
59
+ while (1) switch (_context2.prev = _context2.next) {
60
+ case 0:
61
+ _context2.t0 = format.toUpperCase();
62
+ _context2.next = _context2.t0 === "PDF" ? 3 : _context2.t0 === "SVG" ? 9 : 13;
63
+ break;
64
+ case 3:
65
+ doc = (0, _pdf["default"])(size, margin, buffer);
66
+ stream = new _memorystream["default"](null, {
67
+ readable: false
68
+ });
69
+ doc.pipe(stream);
70
+ doc.on("end", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
71
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
72
+ while (1) switch (_context.prev = _context.next) {
73
+ case 0:
74
+ _context.next = 2;
75
+ return (0, _folder.uploadFile)(output, Buffer.concat(stream.queue).toString(), "".concat(name, " - ").concat(id, ".pdf"), "application/pdf", credentials);
76
+ case 2:
77
+ stream.destroy();
78
+ case 3:
79
+ case "end":
80
+ return _context.stop();
81
+ }
82
+ }, _callee);
83
+ })));
84
+ doc.end();
85
+ return _context2.abrupt("return", id);
86
+ case 9:
87
+ _context2.next = 11;
88
+ return (0, _folder.uploadFile)(output, buffer.toString(), "".concat(name, " - ").concat(id, ".svg"), "image/svg+xml", credentials);
89
+ case 11:
90
+ s = _context2.sent;
91
+ return _context2.abrupt("return", id);
92
+ case 13:
93
+ case "end":
94
+ return _context2.stop();
95
+ }
96
+ }, _callee2);
97
+ }));
98
+ return function (_x10) {
99
+ return _ref5.apply(this, arguments);
100
+ };
101
+ }());
102
+ case 3:
103
+ return _context3.abrupt("return", _context3.sent);
104
+ case 4:
105
+ case "end":
106
+ return _context3.stop();
107
+ }
108
+ }, _callee3);
109
+ }));
110
+ return function (_x9) {
111
+ return _ref4.apply(this, arguments);
112
+ };
113
+ }()));
114
+ case 2:
115
+ return _context4.abrupt("return", _context4.sent);
116
+ case 3:
117
+ case "end":
118
+ return _context4.stop();
119
+ }
120
+ }, _callee4);
121
+ }));
122
+ return function (_x8) {
123
+ return _ref2.apply(this, arguments);
124
+ };
125
+ }());
43
126
  case 5:
44
- images = _context2.sent;
45
- images.forEach(function (_ref2) {
46
- var _ref2$folder = _ref2.folder,
47
- id = _ref2$folder.id,
48
- name = _ref2$folder.name,
49
- qr = _ref2.qr;
50
- return qr.getRawData("svg").then(function (buffer) {
51
- switch (format.toUpperCase()) {
52
- case "PDF":
53
- var doc = (0, _pdf["default"])(size, margin, buffer);
54
- var stream = new _memorystream["default"](null, {
55
- readable: false
56
- });
57
- doc.pipe(stream);
58
- doc.on("end", /*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
59
- return _regeneratorRuntime().wrap(function _callee$(_context) {
60
- while (1) switch (_context.prev = _context.next) {
61
- case 0:
62
- _context.next = 2;
63
- return (0, _folder.uploadFile)(output, Buffer.concat(stream.queue).toString(), "".concat(name, " - ").concat(id, ".pdf"), "application/pdf", credentials);
64
- case 2:
65
- stream.destroy();
66
- case 3:
67
- case "end":
68
- return _context.stop();
69
- }
70
- }, _callee);
71
- })));
72
- doc.end();
73
- return;
74
- case "SVG":
75
- (0, _folder.uploadFile)(output, buffer.toString(), "".concat(name, " - ").concat(id, ".svg"), "image/svg+xml", credentials);
76
- return;
77
- }
78
- });
79
- });
80
- case 7:
127
+ return _context5.abrupt("return", _context5.sent);
128
+ case 6:
81
129
  case "end":
82
- return _context2.stop();
130
+ return _context5.stop();
83
131
  }
84
- }, _callee2);
132
+ }, _callee5);
85
133
  }));
86
134
  return function (_x, _x2, _x3, _x4, _x5, _x6, _x7) {
87
135
  return _ref.apply(this, arguments);
@@ -64,6 +64,8 @@ var _default = exports["default"] = /*#__PURE__*/function () {
64
64
  case 13:
65
65
  console.error("Source Drive or folder is required.");
66
66
  case 14:
67
+ return _context.abrupt("return", []);
68
+ case 15:
67
69
  case "end":
68
70
  return _context.stop();
69
71
  }
@@ -26,46 +26,77 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
26
26
  // See the License for the specific language governing permissions and
27
27
  // limitations under the License.
28
28
  var _default = exports["default"] = /*#__PURE__*/function () {
29
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, output, logo, colors, font, size, margin) {
29
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(drive, output, logo, colors, font, size, margin) {
30
30
  var rounded,
31
31
  format,
32
32
  credentials,
33
- images,
34
- _args = arguments;
35
- return _regeneratorRuntime().wrap(function _callee$(_context) {
36
- while (1) switch (_context.prev = _context.next) {
33
+ _args3 = arguments;
34
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
35
+ while (1) switch (_context3.prev = _context3.next) {
37
36
  case 0:
38
- rounded = _args.length > 7 && _args[7] !== undefined ? _args[7] : false;
39
- format = _args.length > 8 && _args[8] !== undefined ? _args[8] : "PDF";
40
- credentials = _args.length > 9 && _args[9] !== undefined ? _args[9] : null;
41
- _context.next = 5;
42
- return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials);
37
+ rounded = _args3.length > 7 && _args3[7] !== undefined ? _args3[7] : false;
38
+ format = _args3.length > 8 && _args3[8] !== undefined ? _args3[8] : "PDF";
39
+ credentials = _args3.length > 9 && _args3[9] !== undefined ? _args3[9] : null;
40
+ _context3.next = 5;
41
+ return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials).then(/*#__PURE__*/function () {
42
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(images) {
43
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
44
+ while (1) switch (_context2.prev = _context2.next) {
45
+ case 0:
46
+ _context2.next = 2;
47
+ return Promise.all(images.map(/*#__PURE__*/function () {
48
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref3) {
49
+ var _ref3$folder, id, name, qr;
50
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ _ref3$folder = _ref3.folder, id = _ref3$folder.id, name = _ref3$folder.name, qr = _ref3.qr;
54
+ _context.next = 3;
55
+ return qr.getRawData("svg").then(function (buffer) {
56
+ switch (format.toUpperCase()) {
57
+ case "PDF":
58
+ var doc = (0, _pdf["default"])(size, margin, buffer);
59
+ var stream = (0, _fs.createWriteStream)((0, _path.join)(output, "".concat(name, " - ").concat(id, ".pdf")));
60
+ doc.pipe(stream);
61
+ doc.end();
62
+ return stream.path;
63
+ case "SVG":
64
+ var dest = (0, _path.join)(output, "".concat(name, " - ").concat(id, ".svg"));
65
+ (0, _fs.writeFileSync)(dest, buffer.toString());
66
+ return dest;
67
+ }
68
+ });
69
+ case 3:
70
+ return _context.abrupt("return", _context.sent);
71
+ case 4:
72
+ case "end":
73
+ return _context.stop();
74
+ }
75
+ }, _callee);
76
+ }));
77
+ return function (_x9) {
78
+ return _ref4.apply(this, arguments);
79
+ };
80
+ }()));
81
+ case 2:
82
+ return _context2.abrupt("return", _context2.sent);
83
+ case 3:
84
+ case "end":
85
+ return _context2.stop();
86
+ }
87
+ }, _callee2);
88
+ }));
89
+ return function (_x8) {
90
+ return _ref2.apply(this, arguments);
91
+ };
92
+ }());
43
93
  case 5:
44
- images = _context.sent;
45
- images.forEach(function (_ref2) {
46
- var _ref2$folder = _ref2.folder,
47
- id = _ref2$folder.id,
48
- name = _ref2$folder.name,
49
- qr = _ref2.qr;
50
- return qr.getRawData("svg").then(function (buffer) {
51
- switch (format.toUpperCase()) {
52
- case "PDF":
53
- var doc = (0, _pdf["default"])(size, margin, buffer);
54
- var stream = (0, _fs.createWriteStream)((0, _path.join)(output, "".concat(name, " - ").concat(id, ".pdf")));
55
- doc.pipe(stream);
56
- doc.end();
57
- break;
58
- case "SVG":
59
- (0, _fs.writeFileSync)((0, _path.join)(output, "".concat(name, " - ").concat(id, ".svg")), buffer.toString());
60
- break;
61
- }
62
- });
63
- });
64
- case 7:
94
+ return _context3.abrupt("return", _context3.sent);
95
+ case 6:
65
96
  case "end":
66
- return _context.stop();
97
+ return _context3.stop();
67
98
  }
68
- }, _callee);
99
+ }, _callee3);
69
100
  }));
70
101
  return function (_x, _x2, _x3, _x4, _x5, _x6, _x7) {
71
102
  return _ref.apply(this, arguments);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pittica/drive-folder-qrcode",
3
3
  "private": false,
4
- "version": "1.3.1",
4
+ "version": "1.3.2",
5
5
  "description": "Creates QR codes from Google Drive folder names.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {