@pittica/drive-folder-qrcode 1.3.3 → 1.4.0

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.
@@ -7,9 +7,24 @@ exports["default"] = void 0;
7
7
  var _qrCodeStyling = _interopRequireDefault(require("qr-code-styling"));
8
8
  var _jsdom = require("jsdom");
9
9
  var _canvas = _interopRequireDefault(require("canvas"));
10
+ var _deasync = require("deasync");
11
+ var _path = require("path");
12
+ var _fs = require("fs");
13
+ var _memorystream = _interopRequireDefault(require("memorystream"));
14
+ var _pdf2 = _interopRequireDefault(require("../generator/pdf"));
10
15
  var _extension = _interopRequireDefault(require("./extension"));
16
+ var _folder = require("../drive/folder");
11
17
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- // Copyright 2024 Pittica S.r.l.
18
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
19
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
20
+ function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
21
+ function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
22
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
23
+ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
24
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
25
+ function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
26
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
27
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Copyright 2024 Pittica S.r.l.
13
28
  //
14
29
  // Licensed under the Apache License, Version 2.0 (the "License");
15
30
  // you may not use this file except in compliance with the License.
@@ -22,52 +37,250 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
22
37
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
23
38
  // See the License for the specific language governing permissions and
24
39
  // limitations under the License.
25
- var _default = exports["default"] = function _default(_ref, size, margin, image, logo, _ref2, font) {
26
- var name = _ref.name,
27
- webViewLink = _ref.webViewLink;
28
- var fore = _ref2.fore,
29
- dots = _ref2.dots,
30
- square = _ref2.square,
31
- background = _ref2.background,
32
- border = _ref2.border;
33
- var rounded = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
34
- var qr = new _qrCodeStyling["default"]({
35
- jsdom: _jsdom.JSDOM,
36
- nodeCanvas: _canvas["default"],
37
- type: "svg",
38
- width: size,
39
- height: size,
40
- margin: margin,
41
- data: webViewLink,
42
- image: image,
43
- dotsOptions: {
44
- color: fore,
45
- type: rounded ? "dots" : "square"
46
- },
47
- cornersDotOptions: {
48
- color: dots,
49
- type: rounded ? "dot" : "square"
50
- },
51
- cornersSquareOptions: {
52
- color: square,
53
- type: rounded ? "extra-rounded" : "square"
54
- },
55
- backgroundOptions: {
56
- color: background
57
- },
58
- borderOptions: {
59
- color: border
60
- },
61
- imageOptions: {
62
- saveAsBlob: false,
63
- crossOrigin: "anonymous",
40
+ /**
41
+ * QR code image class.
42
+ */
43
+ var Image = exports["default"] = /*#__PURE__*/function () {
44
+ /**
45
+ *
46
+ * @param {object} folder Google Drive input folder.
47
+ * @param {Number} size QR code size.
48
+ * @param {Number} margin QR code margin.
49
+ * @param {string} image Logo path.
50
+ * @param {string} logo Logo XML/SVG data.
51
+ * @param {object} setting QR code settings.
52
+ * @param {object} font Font settings.
53
+ * @param {boolean} rounded A value indicating whetherthe QR code uses rounded corners and dots.
54
+ * @param {string} caption QR code caption.
55
+ */
56
+ function Image(_ref, size, margin, image, logo, _ref2, font) {
57
+ var id = _ref.id,
58
+ name = _ref.name,
59
+ webViewLink = _ref.webViewLink;
60
+ var fore = _ref2.fore,
61
+ dots = _ref2.dots,
62
+ square = _ref2.square,
63
+ background = _ref2.background,
64
+ border = _ref2.border;
65
+ var rounded = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
66
+ var caption = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
67
+ _classCallCheck(this, Image);
68
+ _defineProperty(this, "_buffer", null);
69
+ this._settings = {
70
+ id: id,
71
+ name: name,
72
+ webViewLink: webViewLink,
73
+ size: size,
64
74
  margin: margin
65
- },
66
- caption: name,
67
- logo: logo,
68
- font: font,
69
- rounded: rounded
70
- });
71
- qr.applyExtension(_extension["default"]);
72
- return qr;
73
- };
75
+ };
76
+ this._qr = new _qrCodeStyling["default"]({
77
+ jsdom: _jsdom.JSDOM,
78
+ nodeCanvas: _canvas["default"],
79
+ type: "svg",
80
+ width: size,
81
+ height: size,
82
+ margin: margin,
83
+ data: webViewLink,
84
+ image: image,
85
+ dotsOptions: {
86
+ color: fore,
87
+ type: rounded ? "dots" : "square"
88
+ },
89
+ cornersDotOptions: {
90
+ color: dots,
91
+ type: rounded ? "dot" : "square"
92
+ },
93
+ cornersSquareOptions: {
94
+ color: square,
95
+ type: rounded ? "extra-rounded" : "square"
96
+ },
97
+ backgroundOptions: {
98
+ color: background
99
+ },
100
+ borderOptions: {
101
+ color: border
102
+ },
103
+ imageOptions: {
104
+ saveAsBlob: false,
105
+ crossOrigin: "anonymous",
106
+ margin: margin
107
+ },
108
+ caption: caption || name,
109
+ logo: logo,
110
+ font: font,
111
+ rounded: rounded
112
+ });
113
+ this._qr.applyExtension(_extension["default"]);
114
+ }
115
+
116
+ /**
117
+ * Gets an output filename.
118
+ *
119
+ * @param {string} extension File extension.
120
+ * @returns {string} Output filename.
121
+ */
122
+ return _createClass(Image, [{
123
+ key: "filename",
124
+ value: function filename(extension) {
125
+ return (0, _folder.filename)(this._settings, extension);
126
+ }
127
+ }, {
128
+ key: "pdf",
129
+ value: function pdf(stream, buffer, callback) {
130
+ var lock = true;
131
+ var result = null;
132
+ var doc = (0, _pdf2["default"])(this._settings.size, this._settings.margin, buffer);
133
+ doc.pipe(stream);
134
+ doc.once("end", function () {
135
+ if (typeof callback === "function") {
136
+ result = callback(stream);
137
+ }
138
+ lock = false;
139
+ });
140
+ doc.end();
141
+ (0, _deasync.loopWhile)(function () {
142
+ return lock;
143
+ });
144
+ return result;
145
+ }
146
+
147
+ /**
148
+ * Saves the QR code locally.
149
+ *
150
+ * @param {string} output Output folder.
151
+ * @param {string} format Output format.
152
+ * @returns {string} The destination path.
153
+ */
154
+ }, {
155
+ key: "save",
156
+ value: (function () {
157
+ var _save = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(output) {
158
+ var _this = this;
159
+ var format,
160
+ _args = arguments;
161
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
162
+ while (1) switch (_context.prev = _context.next) {
163
+ case 0:
164
+ format = _args.length > 1 && _args[1] !== undefined ? _args[1] : "PDF";
165
+ _context.next = 3;
166
+ return this._qr.getRawData("svg").then(function (buffer) {
167
+ switch (format.toUpperCase()) {
168
+ case "PDF":
169
+ var stream = (0, _fs.createWriteStream)((0, _path.join)(output, _this.filename(format)));
170
+ var result = _this.pdf(stream, buffer, function (stream) {
171
+ return stream.path;
172
+ });
173
+ stream.close();
174
+ return result;
175
+ case "SVG":
176
+ var dest = (0, _path.join)(output, _this.filename(format));
177
+ (0, _fs.writeFileSync)(dest, buffer.toString());
178
+ return dest;
179
+ default:
180
+ return null;
181
+ }
182
+ });
183
+ case 3:
184
+ return _context.abrupt("return", _context.sent);
185
+ case 4:
186
+ case "end":
187
+ return _context.stop();
188
+ }
189
+ }, _callee, this);
190
+ }));
191
+ function save(_x) {
192
+ return _save.apply(this, arguments);
193
+ }
194
+ return save;
195
+ }()
196
+ /**
197
+ * Saves the QR code to Google Drive.
198
+ *
199
+ * @param {string} output Google Drive output folder ID.
200
+ * @param {string} format Output format.
201
+ * @param {string} credentials Service account JSON file path.
202
+ * @returns {string} The destination ID.
203
+ */
204
+ )
205
+ }, {
206
+ key: "upload",
207
+ value: (function () {
208
+ var _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(output) {
209
+ var _this2 = this;
210
+ var format,
211
+ credentials,
212
+ _args4 = arguments;
213
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
214
+ while (1) switch (_context4.prev = _context4.next) {
215
+ case 0:
216
+ format = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : "PDF";
217
+ credentials = _args4.length > 2 ? _args4[2] : undefined;
218
+ _context4.next = 4;
219
+ return this._qr.getRawData("svg").then(/*#__PURE__*/function () {
220
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buffer) {
221
+ var stream, file, _yield$uploadFile, id;
222
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
223
+ while (1) switch (_context3.prev = _context3.next) {
224
+ case 0:
225
+ _context3.t0 = format.toUpperCase();
226
+ _context3.next = _context3.t0 === "PDF" ? 3 : _context3.t0 === "SVG" ? 7 : 12;
227
+ break;
228
+ case 3:
229
+ stream = new _memorystream["default"](null, {
230
+ readable: false
231
+ });
232
+ file = _this2.pdf(stream, buffer, /*#__PURE__*/function () {
233
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(stream) {
234
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
235
+ while (1) switch (_context2.prev = _context2.next) {
236
+ case 0:
237
+ _context2.next = 2;
238
+ return (0, _folder.uploadFile)(output, Buffer.concat(stream.queue).toString(), _this2.filename(format), "application/pdf", credentials);
239
+ case 2:
240
+ return _context2.abrupt("return", _context2.sent);
241
+ case 3:
242
+ case "end":
243
+ return _context2.stop();
244
+ }
245
+ }, _callee2);
246
+ }));
247
+ return function (_x4) {
248
+ return _ref4.apply(this, arguments);
249
+ };
250
+ }());
251
+ stream.destroy();
252
+ return _context3.abrupt("return", file.id);
253
+ case 7:
254
+ _context3.next = 9;
255
+ return (0, _folder.uploadFile)(output, buffer.toString(), _this2.filename(format), "image/svg+xml", credentials);
256
+ case 9:
257
+ _yield$uploadFile = _context3.sent;
258
+ id = _yield$uploadFile.id;
259
+ return _context3.abrupt("return", id);
260
+ case 12:
261
+ return _context3.abrupt("return", null);
262
+ case 13:
263
+ case "end":
264
+ return _context3.stop();
265
+ }
266
+ }, _callee3);
267
+ }));
268
+ return function (_x3) {
269
+ return _ref3.apply(this, arguments);
270
+ };
271
+ }());
272
+ case 4:
273
+ return _context4.abrupt("return", _context4.sent);
274
+ case 5:
275
+ case "end":
276
+ return _context4.stop();
277
+ }
278
+ }, _callee4, this);
279
+ }));
280
+ function upload(_x2) {
281
+ return _upload.apply(this, arguments);
282
+ }
283
+ return upload;
284
+ }())
285
+ }]);
286
+ }();
@@ -4,7 +4,7 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.resize = exports.getFile = exports.getContent = void 0;
7
+ exports.resize = exports.getFile = exports.getData = exports.getContent = void 0;
8
8
  var _svgo = require("svgo");
9
9
  var _axios = _interopRequireDefault(require("axios"));
10
10
  var _svg = require("@svgdotjs/svg.js");
@@ -75,6 +75,35 @@ var getContent = exports.getContent = /*#__PURE__*/function () {
75
75
  };
76
76
  }();
77
77
 
78
+ /**
79
+ * Gets file content from the given file path
80
+ *
81
+ * @param {string} file File path.
82
+ * @param {Number} size Resize size.
83
+ * @returns {string} File content from the given file path
84
+ */
85
+ var getData = exports.getData = /*#__PURE__*/function () {
86
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(file, size) {
87
+ var data;
88
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
+ while (1) switch (_context2.prev = _context2.next) {
90
+ case 0:
91
+ _context2.next = 2;
92
+ return getContent(file);
93
+ case 2:
94
+ data = _context2.sent;
95
+ return _context2.abrupt("return", data ? resize(data, size) : null);
96
+ case 4:
97
+ case "end":
98
+ return _context2.stop();
99
+ }
100
+ }, _callee2);
101
+ }));
102
+ return function getData(_x2, _x3) {
103
+ return _ref3.apply(this, arguments);
104
+ };
105
+ }();
106
+
78
107
  /**
79
108
  * Gets file content from the given file path
80
109
  *
@@ -96,7 +125,7 @@ var getFile = exports.getFile = function getFile(file) {
96
125
  *
97
126
  * @param {string} data SVG data.
98
127
  * @param {Number} size Greather side size of the logo.
99
- * @returns Resized logo.
128
+ * @returns {string} Resized logo.
100
129
  */
101
130
  var resize = exports.resize = function resize(data, size) {
102
131
  var win = (0, _window["default"])(data);
package/dist/scripts.js CHANGED
@@ -34,7 +34,9 @@ var drive = exports.drive = /*#__PURE__*/function () {
34
34
  colorBorder,
35
35
  fontFamily,
36
36
  fontPath,
37
+ fontColor,
37
38
  rounded,
39
+ callback,
38
40
  _args = arguments;
39
41
  return _regeneratorRuntime().wrap(function _callee$(_context) {
40
42
  while (1) switch (_context.prev = _context.next) {
@@ -48,8 +50,10 @@ var drive = exports.drive = /*#__PURE__*/function () {
48
50
  colorBorder = _args.length > 11 && _args[11] !== undefined ? _args[11] : "#000000";
49
51
  fontFamily = _args.length > 12 && _args[12] !== undefined ? _args[12] : "Arial";
50
52
  fontPath = _args.length > 13 && _args[13] !== undefined ? _args[13] : null;
51
- rounded = _args.length > 14 && _args[14] !== undefined ? _args[14] : true;
52
- _context.next = 12;
53
+ fontColor = _args.length > 14 && _args[14] !== undefined ? _args[14] : null;
54
+ rounded = _args.length > 15 && _args[15] !== undefined ? _args[15] : false;
55
+ callback = _args.length > 16 && _args[16] !== undefined ? _args[16] : null;
56
+ _context.next = 14;
53
57
  return (0, _drive2["default"])(_drive, output, logo, {
54
58
  fore: colorFore,
55
59
  dots: colorDots,
@@ -58,11 +62,12 @@ var drive = exports.drive = /*#__PURE__*/function () {
58
62
  border: colorBorder
59
63
  }, {
60
64
  path: fontPath,
61
- family: fontFamily
62
- }, parseFloat(size), parseFloat(margin), rounded, format, credentials);
63
- case 12:
65
+ family: fontFamily,
66
+ color: fontColor
67
+ }, parseFloat(size), parseFloat(margin), rounded, format, credentials, callback);
68
+ case 14:
64
69
  return _context.abrupt("return", _context.sent);
65
- case 13:
70
+ case 15:
66
71
  case "end":
67
72
  return _context.stop();
68
73
  }
@@ -83,7 +88,9 @@ var local = exports.local = /*#__PURE__*/function () {
83
88
  colorBorder,
84
89
  fontFamily,
85
90
  fontPath,
91
+ fontColor,
86
92
  rounded,
93
+ callback,
87
94
  _args2 = arguments;
88
95
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
89
96
  while (1) switch (_context2.prev = _context2.next) {
@@ -97,8 +104,10 @@ var local = exports.local = /*#__PURE__*/function () {
97
104
  colorBorder = _args2.length > 11 && _args2[11] !== undefined ? _args2[11] : "#000000";
98
105
  fontFamily = _args2.length > 12 && _args2[12] !== undefined ? _args2[12] : "Arial";
99
106
  fontPath = _args2.length > 13 && _args2[13] !== undefined ? _args2[13] : null;
100
- rounded = _args2.length > 14 && _args2[14] !== undefined ? _args2[14] : false;
101
- _context2.next = 12;
107
+ fontColor = _args2.length > 14 && _args2[14] !== undefined ? _args2[14] : null;
108
+ rounded = _args2.length > 15 && _args2[15] !== undefined ? _args2[15] : false;
109
+ callback = _args2.length > 16 && _args2[16] !== undefined ? _args2[16] : null;
110
+ _context2.next = 14;
102
111
  return (0, _local["default"])(drive, output, logo, {
103
112
  fore: colorFore,
104
113
  dots: colorDots,
@@ -107,11 +116,12 @@ var local = exports.local = /*#__PURE__*/function () {
107
116
  border: colorBorder
108
117
  }, {
109
118
  path: fontPath,
110
- family: fontFamily
111
- }, parseFloat(size), parseFloat(margin), rounded, format, credentials);
112
- case 12:
119
+ family: fontFamily,
120
+ color: fontColor
121
+ }, parseFloat(size), parseFloat(margin), rounded, format, credentials, callback);
122
+ case 14:
113
123
  return _context2.abrupt("return", _context2.sent);
114
- case 13:
124
+ case 15:
115
125
  case "end":
116
126
  return _context2.stop();
117
127
  }
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.3",
4
+ "version": "1.4.0",
5
5
  "description": "Creates QR codes from Google Drive folder names.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -33,6 +33,7 @@
33
33
  "@svgdotjs/svg.js": "^3.2.4",
34
34
  "axios": "^1.7.7",
35
35
  "canvas": "^2.11.2",
36
+ "deasync": "^0.1.30",
36
37
  "googleapis": "^144.0.0",
37
38
  "jsdom": "^25.0.1",
38
39
  "memorystream": "^0.3.1",