@pittica/drive-folder-qrcode 1.5.1 → 2.0.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.
@@ -1,20 +1,26 @@
1
1
  "use strict";
2
2
 
3
- 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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
- exports.resize = exports.getFile = exports.getData = exports.getContent = void 0;
6
+ exports["default"] = void 0;
8
7
  var _svgo = require("svgo");
9
8
  var _axios = _interopRequireDefault(require("axios"));
10
9
  var _svg = require("@svgdotjs/svg.js");
11
10
  var _url = require("url");
12
11
  var _fs = _interopRequireDefault(require("fs"));
13
- var _window = _interopRequireDefault(require("./window"));
12
+ var _window2 = _interopRequireDefault(require("./window"));
14
13
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { 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 && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
14
+ 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); }
15
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), c(GeneratorFunctionPrototype, u, GeneratorFunction.displayName = "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { 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 && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
16
16
  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); }
17
- 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); }); }; } // Copyright 2024-2025 Pittica S.r.l.
17
+ 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); }); }; }
18
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
19
+ 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); } }
20
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
21
+ 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; }
22
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
23
+ 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-2025 Pittica S.r.l.
18
24
  //
19
25
  // Licensed under the Apache License, Version 2.0 (the "License");
20
26
  // you may not use this file except in compliance with the License.
@@ -28,112 +34,141 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
28
34
  // See the License for the specific language governing permissions and
29
35
  // limitations under the License.
30
36
  /**
31
- * Gets the logo content.
32
- *
33
- * @param {string} file File path or URL.
34
- * @returns {Output} The logo content.
37
+ * Logo class and helpers.
35
38
  */
36
- var getContent = exports.getContent = /*#__PURE__*/function () {
37
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
38
- var url, protocol, _yield$axios$get$then, data;
39
- return _regeneratorRuntime().wrap(function _callee$(_context) {
40
- while (1) switch (_context.prev = _context.next) {
41
- case 0:
42
- _context.prev = 0;
43
- url = new _url.URL(file);
44
- protocol = url.protocol.toUpperCase();
45
- if (!(protocol === "HTTPS:" || protocol === "HTTP:")) {
46
- _context.next = 11;
47
- break;
39
+ var Logo = exports["default"] = /*#__PURE__*/function () {
40
+ /**
41
+ * Creates a new instance of the Logo class.
42
+ *
43
+ * @param {string} file File path or URL.
44
+ */
45
+ function Logo(file) {
46
+ _classCallCheck(this, Logo);
47
+ _defineProperty(this, "_file", "");
48
+ this._file = file;
49
+ }
50
+
51
+ /**
52
+ * Gets the logo content.
53
+ *
54
+ * @returns {Output} The logo content.
55
+ */
56
+ return _createClass(Logo, [{
57
+ key: "getContent",
58
+ value: (function () {
59
+ var _getContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
60
+ var url, protocol, _yield$axios$get$then, data;
61
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
62
+ while (1) switch (_context.prev = _context.next) {
63
+ case 0:
64
+ _context.prev = 0;
65
+ url = new _url.URL(this._file);
66
+ protocol = url.protocol.toUpperCase();
67
+ if (!(protocol === "HTTPS:" || protocol === "HTTP:")) {
68
+ _context.next = 11;
69
+ break;
70
+ }
71
+ _context.next = 6;
72
+ return _axios["default"].get(url).then(function (_ref) {
73
+ var data = _ref.data;
74
+ return (0, _svgo.optimize)(data);
75
+ });
76
+ case 6:
77
+ _yield$axios$get$then = _context.sent;
78
+ data = _yield$axios$get$then.data;
79
+ return _context.abrupt("return", data);
80
+ case 11:
81
+ return _context.abrupt("return", this.getFile(this._file));
82
+ case 12:
83
+ _context.next = 17;
84
+ break;
85
+ case 14:
86
+ _context.prev = 14;
87
+ _context.t0 = _context["catch"](0);
88
+ return _context.abrupt("return", this.getFile(this._file));
89
+ case 17:
90
+ case "end":
91
+ return _context.stop();
48
92
  }
49
- _context.next = 6;
50
- return _axios["default"].get(url).then(function (_ref2) {
51
- var data = _ref2.data;
52
- return (0, _svgo.optimize)(data);
53
- });
54
- case 6:
55
- _yield$axios$get$then = _context.sent;
56
- data = _yield$axios$get$then.data;
57
- return _context.abrupt("return", data);
58
- case 11:
59
- return _context.abrupt("return", getFile(file));
60
- case 12:
61
- _context.next = 17;
62
- break;
63
- case 14:
64
- _context.prev = 14;
65
- _context.t0 = _context["catch"](0);
66
- return _context.abrupt("return", getFile(file));
67
- case 17:
68
- case "end":
69
- return _context.stop();
93
+ }, _callee, this, [[0, 14]]);
94
+ }));
95
+ function getContent() {
96
+ return _getContent.apply(this, arguments);
70
97
  }
71
- }, _callee, null, [[0, 14]]);
72
- }));
73
- return function getContent(_x) {
74
- return _ref.apply(this, arguments);
75
- };
76
- }();
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();
98
+ return getContent;
99
+ }()
100
+ /**
101
+ * Gets file content from the given file path
102
+ *
103
+ * @param {Number} size Resize size.
104
+ * @returns {string} File content from the given file path
105
+ */
106
+ )
107
+ }, {
108
+ key: "getData",
109
+ value: (function () {
110
+ var _getData = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(size) {
111
+ var data;
112
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
113
+ while (1) switch (_context2.prev = _context2.next) {
114
+ case 0:
115
+ _context2.next = 2;
116
+ return this.getContent();
117
+ case 2:
118
+ data = _context2.sent;
119
+ return _context2.abrupt("return", data ? this.resize(data, size) : null);
120
+ case 4:
121
+ case "end":
122
+ return _context2.stop();
123
+ }
124
+ }, _callee2, this);
125
+ }));
126
+ function getData(_x) {
127
+ return _getData.apply(this, arguments);
99
128
  }
100
- }, _callee2);
101
- }));
102
- return function getData(_x2, _x3) {
103
- return _ref3.apply(this, arguments);
104
- };
105
- }();
106
-
107
- /**
108
- * Gets file content from the given file path
109
- *
110
- * @param {string} file File path.
111
- * @returns {string} File content from the given file path
112
- */
113
- var getFile = exports.getFile = function getFile(file) {
114
- try {
115
- var _optimize = (0, _svgo.optimize)(_fs["default"].readFileSync(file)),
116
- data = _optimize.data;
117
- return data;
118
- } catch (_unused) {
119
- return null;
120
- }
121
- };
129
+ return getData;
130
+ }()
131
+ /**
132
+ * Gets file content from the given file path
133
+ *
134
+ * @returns {string} File content from the given file path
135
+ */
136
+ )
137
+ }, {
138
+ key: "getFile",
139
+ value: function getFile() {
140
+ try {
141
+ var _window = (0, _window2["default"])(_fs["default"].readFileSync(this._file)),
142
+ document = _window.document;
143
+ var svg = document.getElementsByTagName("svg")[0];
144
+ svg.removeAttribute("width");
145
+ svg.removeAttribute("height");
146
+ var _optimize = (0, _svgo.optimize)(svg.outerHTML),
147
+ data = _optimize.data;
148
+ return data;
149
+ } catch (_unused) {
150
+ return null;
151
+ }
152
+ }
122
153
 
123
- /**
124
- * Resizes a logo from the given data.
125
- *
126
- * @param {string} data SVG data.
127
- * @param {Number} size Greather side size of the logo.
128
- * @returns {string} Resized logo.
129
- */
130
- var resize = exports.resize = function resize(data, size) {
131
- var win = (0, _window["default"])(data);
132
- (0, _svg.registerWindow)(win, win.document);
133
- var svg = (0, _svg.SVG)(data);
134
- var width = size / 5;
135
- var x = size / 2 - width / 2;
136
- svg.size(width, width);
137
- svg.move(x, x);
138
- return svg.xml();
139
- };
154
+ /**
155
+ * Resizes a logo from the given data.
156
+ *
157
+ * @param {string} data SVG data.
158
+ * @param {Number} size Greather side size of the logo.
159
+ * @returns {string} Resized logo.
160
+ */
161
+ }, {
162
+ key: "resize",
163
+ value: function resize(data, size) {
164
+ var win = (0, _window2["default"])(data);
165
+ (0, _svg.registerWindow)(win, win.document);
166
+ var svg = (0, _svg.SVG)(data);
167
+ var width = size / 5;
168
+ var x = size / 2 - width / 2;
169
+ svg.size(width, width);
170
+ svg.move(x, x);
171
+ return svg.xml();
172
+ }
173
+ }]);
174
+ }();
package/dist/scripts.js CHANGED
@@ -7,9 +7,9 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports.local = exports.drive = exports["default"] = exports.count = void 0;
8
8
  var _local = _interopRequireDefault(require("./generator/local"));
9
9
  var _drive2 = _interopRequireDefault(require("./generator/drive"));
10
- var _folder = require("./drive/folder");
10
+ var _client = _interopRequireDefault(require("./drive/client"));
11
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
12
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { 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 && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
12
+ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), c(GeneratorFunctionPrototype, u, GeneratorFunction.displayName = "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { 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 && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
13
13
  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); }
14
14
  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); }); }; } // Copyright 2024-2025 Pittica S.r.l.
15
15
  //
@@ -24,29 +24,26 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
24
24
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
25
25
  // See the License for the specific language governing permissions and
26
26
  // limitations under the License.
27
+ /**
28
+ * Counts the files contained in scan and destination folders.
29
+ *
30
+ * @param {string} drive Scan folder ID.
31
+ * @param {string} output Destination folder ID.
32
+ * @param {string|object|null} credentials Credentials object or JSON file path.
33
+ * @returns {object} Count of the files in the given folders.
34
+ */
27
35
  var count = exports.count = /*#__PURE__*/function () {
28
36
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, output) {
29
37
  var credentials,
30
- folders,
31
- existings,
38
+ client,
32
39
  _args = arguments;
33
40
  return _regeneratorRuntime().wrap(function _callee$(_context) {
34
41
  while (1) switch (_context.prev = _context.next) {
35
42
  case 0:
36
43
  credentials = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
37
- _context.next = 3;
38
- return (0, _folder.list)(drive, credentials);
44
+ client = new _client["default"](credentials);
45
+ return _context.abrupt("return", client.count(drive, output));
39
46
  case 3:
40
- folders = _context.sent;
41
- _context.next = 6;
42
- return (0, _folder.list)(output, credentials);
43
- case 6:
44
- existings = _context.sent;
45
- return _context.abrupt("return", {
46
- "in": folders.length,
47
- out: existings.length
48
- });
49
- case 8:
50
47
  case "end":
51
48
  return _context.stop();
52
49
  }
@@ -56,6 +53,29 @@ var count = exports.count = /*#__PURE__*/function () {
56
53
  return _ref.apply(this, arguments);
57
54
  };
58
55
  }();
56
+
57
+ /**
58
+ * Generates QR codes in the Google Drive given folder.
59
+ *
60
+ * @param {string} drive Source folder ID.
61
+ * @param {string} output Output folder folder ID.
62
+ * @param {string} logo Logo image path.
63
+ * @param {number} size QR code size.
64
+ * @param {number} margin QR code margin.
65
+ * @param {string} format Output format.
66
+ * @param {string|object|null} credentials Credentials object or JSON file path.
67
+ * @param {string} colorFore Foreground color.
68
+ * @param {string} colorDots Dots color.
69
+ * @param {string} colorSquare Square color.
70
+ * @param {string} colorBackground Background color.
71
+ * @param {string} colorBorder Border color.
72
+ * @param {string} fontFamily Font family.
73
+ * @param {string} fontPath Font path.
74
+ * @param {string} fontColor Font color.
75
+ * @param {boolean} rounded A value indicating whether the image has a rounded border.
76
+ * @param {function} callback Caption text filter.
77
+ * @returns {boolean} A value indicating whether the file has been created.
78
+ */
59
79
  var drive = exports.drive = /*#__PURE__*/function () {
60
80
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_drive, output, logo, size, margin) {
61
81
  var format,
@@ -110,6 +130,29 @@ var drive = exports.drive = /*#__PURE__*/function () {
110
130
  return _ref2.apply(this, arguments);
111
131
  };
112
132
  }();
133
+
134
+ /**
135
+ * Generates QR codes in the local given folder.
136
+ *
137
+ * @param {string} drive Source folder ID.
138
+ * @param {string} output Output folder folder ID.
139
+ * @param {string} logo Logo image path.
140
+ * @param {number} size QR code size.
141
+ * @param {number} margin QR code margin.
142
+ * @param {string} format Output format.
143
+ * @param {string|object|null} credentials Credentials object or JSON file path.
144
+ * @param {string} colorFore Foreground color.
145
+ * @param {string} colorDots Dots color.
146
+ * @param {string} colorSquare Square color.
147
+ * @param {string} colorBackground Background color.
148
+ * @param {string} colorBorder Border color.
149
+ * @param {string} fontFamily Font family.
150
+ * @param {string} fontPath Font path.
151
+ * @param {string} fontColor Font color.
152
+ * @param {boolean} rounded A value indicating whether the image has a rounded border.
153
+ * @param {function} callback Caption text filter.
154
+ * @returns {boolean} A value indicating whether the file has been created.
155
+ */
113
156
  var local = exports.local = /*#__PURE__*/function () {
114
157
  var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(drive, output, logo, size, margin) {
115
158
  var format,
@@ -0,0 +1,184 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ 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); }
8
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
9
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
10
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
11
+ 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); } }
12
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
13
+ 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; }
14
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
15
+ 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); }
16
+ // Copyright 2024-2025 Pittica S.r.l.
17
+ //
18
+ // Licensed under the Apache License, Version 2.0 (the "License");
19
+ // you may not use this file except in compliance with the License.
20
+ // You may obtain a copy of the License at
21
+ //
22
+ // http://www.apache.org/licenses/LICENSE-2.0
23
+ //
24
+ // Unless required by applicable law or agreed to in writing, software
25
+ // distributed under the License is distributed on an "AS IS" BASIS,
26
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
27
+ // See the License for the specific language governing permissions and
28
+ // limitations under the License.
29
+ /**
30
+ * Default settings.
31
+ */
32
+ var Settngs = exports["default"] = /*#__PURE__*/function () {
33
+ /**
34
+ * Creates a new instance of Settings.
35
+ *
36
+ * @param {string} file File path.
37
+ */
38
+ function Settngs() {
39
+ var file = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
40
+ _classCallCheck(this, Settngs);
41
+ _defineProperty(this, "_settings", {});
42
+ try {
43
+ this._settings = require(file);
44
+ } catch (_unused) {
45
+ this._settings = {};
46
+ }
47
+ this.loadSettings();
48
+ }
49
+
50
+ /**
51
+ * Loads the default settings.
52
+ */
53
+ return _createClass(Settngs, [{
54
+ key: "loadSettings",
55
+ value: function loadSettings() {
56
+ var _this$_settings = this._settings,
57
+ destination = _this$_settings.destination,
58
+ settings = _this$_settings.settings,
59
+ colors = _this$_settings.colors,
60
+ font = _this$_settings.font;
61
+ this._settings.source = this._settings.source || process.env.DRIVE_QRCODER_SOURCE;
62
+ this._settings.destination = _objectSpread(_objectSpread({}, {
63
+ drive: process.env.DRIVE_QRCODER_DESTINATION_DRIVE || null,
64
+ local: process.env.DRIVE_QRCODER_DESTINATION_LOCAL || null
65
+ }), destination);
66
+ this._settings.settings = _objectSpread(_objectSpread({}, {
67
+ size: typeof process.env.DRIVE_QRCODER_SIZE === "undefined" ? 300 : parseInt(process.env.DRIVE_QRCODER_SIZE),
68
+ margin: typeof process.env.DRIVE_QRCODER_MARGIN === "undefined" ? 15 : parseInt(process.env.DRIVE_QRCODER_MARGIN),
69
+ rouded: process.env.DRIVE_QRCODER_ROUNDED ? true : false,
70
+ format: process.env.DRIVE_QRCODER_FORMAT || "PDF"
71
+ }), settings);
72
+ this._settings.colors = _objectSpread(_objectSpread({}, {
73
+ fore: process.env.DRIVE_QRCODER_COLOR_FORE || "#000000",
74
+ dots: process.env.DRIVE_QRCODER_COLOR_DOTS || "#000000",
75
+ square: process.env.DRIVE_QRCODER_COLOR_SQUARE || "#000000",
76
+ background: process.env.DRIVE_QRCODER_COLOR_BACKGROUND || "#ffffff",
77
+ border: process.env.DRIVE_QRCODER_COLOR_BORDER || "#000000"
78
+ }), colors);
79
+ this._settings.font = _objectSpread(_objectSpread({}, {
80
+ color: process.env.DRIVE_QRCODER_FONT_COLOR || "#ffffff",
81
+ path: process.env.DRIVE_QRCODER_FONT_PATH || null,
82
+ family: process.env.DRIVE_QRCODER_FONT_FAMILY || "Arial"
83
+ }), font);
84
+ }
85
+
86
+ /**
87
+ * Gets the Google Drive ID of the source folder.
88
+ *
89
+ * @returns {string|null} The Google Drive ID of the source folder.
90
+ */
91
+ }, {
92
+ key: "getSource",
93
+ value: function getSource() {
94
+ return this._settings.source;
95
+ }
96
+
97
+ /**
98
+ * Gets the destination settings.
99
+ *
100
+ * @returns {object} Destination settings.
101
+ */
102
+ }, {
103
+ key: "getDestination",
104
+ value: function getDestination() {
105
+ var destination = this._settings.destination;
106
+ return destination;
107
+ }
108
+
109
+ /**
110
+ * Gets the image settings.
111
+ *
112
+ * @returns {object} Image settings.
113
+ */
114
+ }, {
115
+ key: "getSettings",
116
+ value: function getSettings() {
117
+ var settings = this._settings.settings;
118
+ return settings;
119
+ }
120
+
121
+ /**
122
+ * Gets the image color settings.
123
+ *
124
+ * @returns {object} Image color settings.
125
+ */
126
+ }, {
127
+ key: "getColors",
128
+ value: function getColors() {
129
+ var colors = this._settings.colors;
130
+ return colors;
131
+ }
132
+
133
+ /**
134
+ * Gets the font settings.
135
+ *
136
+ * @returns {object} Font settings.
137
+ */
138
+ }, {
139
+ key: "getFont",
140
+ value: function getFont() {
141
+ var font = this._settings.font;
142
+ return font;
143
+ }
144
+
145
+ /**
146
+ * Merges settings.
147
+ *
148
+ * @param {string} source The Google Drive ID of the source folder.
149
+ * @param {object} destination Destination settings.
150
+ * @param {object} settings Image settings.
151
+ * @param {object} colors Image color settings.
152
+ * @param {object} font Font settings.
153
+ */
154
+ }, {
155
+ key: "merge",
156
+ value: function merge(source, destination, settings, colors, font) {
157
+ return {
158
+ source: source || this.getSource(),
159
+ destination: _objectSpread(_objectSpread({}, this.getDestination()), this.filter(destination)),
160
+ settings: _objectSpread(_objectSpread({}, this.getSettings()), this.filter(settings)),
161
+ colors: _objectSpread(_objectSpread({}, this.getColors()), this.filter(colors)),
162
+ font: _objectSpread(_objectSpread({}, this.getFont()), this.filter(font))
163
+ };
164
+ }
165
+
166
+ /**
167
+ * Filter the given value and removes empty objects.
168
+ *
169
+ * @param {object} value The value to filter.
170
+ * @returns {object} Cleaned object.
171
+ */
172
+ }, {
173
+ key: "filter",
174
+ value: function filter(value) {
175
+ var result = {};
176
+ Object.keys(value).forEach(function (key) {
177
+ if (value[key] !== "" && value[key] !== null) {
178
+ result[key] = value[key];
179
+ }
180
+ });
181
+ return result;
182
+ }
183
+ }]);
184
+ }();