@pittica/drive-folder-qrcode 1.4.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.
package/dist/scripts.js CHANGED
@@ -4,13 +4,14 @@ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" ==
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.local = exports.drive = exports["default"] = void 0;
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 _client = _interopRequireDefault(require("./drive/client"));
10
11
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
11
- 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; }
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; }
12
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); }
13
- 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 Pittica S.r.l.
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.
14
15
  //
15
16
  // Licensed under the Apache License, Version 2.0 (the "License");
16
17
  // you may not use this file except in compliance with the License.
@@ -23,8 +24,60 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
23
24
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
24
25
  // See the License for the specific language governing permissions and
25
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
+ */
35
+ var count = exports.count = /*#__PURE__*/function () {
36
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, output) {
37
+ var credentials,
38
+ client,
39
+ _args = arguments;
40
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
41
+ while (1) switch (_context.prev = _context.next) {
42
+ case 0:
43
+ credentials = _args.length > 2 && _args[2] !== undefined ? _args[2] : null;
44
+ client = new _client["default"](credentials);
45
+ return _context.abrupt("return", client.count(drive, output));
46
+ case 3:
47
+ case "end":
48
+ return _context.stop();
49
+ }
50
+ }, _callee);
51
+ }));
52
+ return function count(_x, _x2) {
53
+ return _ref.apply(this, arguments);
54
+ };
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
+ */
26
79
  var drive = exports.drive = /*#__PURE__*/function () {
27
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(_drive, output, logo, size, margin) {
80
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(_drive, output, logo, size, margin) {
28
81
  var format,
29
82
  credentials,
30
83
  colorFore,
@@ -37,23 +90,23 @@ var drive = exports.drive = /*#__PURE__*/function () {
37
90
  fontColor,
38
91
  rounded,
39
92
  callback,
40
- _args = arguments;
41
- return _regeneratorRuntime().wrap(function _callee$(_context) {
42
- while (1) switch (_context.prev = _context.next) {
93
+ _args2 = arguments;
94
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
95
+ while (1) switch (_context2.prev = _context2.next) {
43
96
  case 0:
44
- format = _args.length > 5 && _args[5] !== undefined ? _args[5] : "PDF";
45
- credentials = _args.length > 6 && _args[6] !== undefined ? _args[6] : null;
46
- colorFore = _args.length > 7 && _args[7] !== undefined ? _args[7] : "#000000";
47
- colorDots = _args.length > 8 && _args[8] !== undefined ? _args[8] : "#000000";
48
- colorSquare = _args.length > 9 && _args[9] !== undefined ? _args[9] : "#000000";
49
- colorBackground = _args.length > 10 && _args[10] !== undefined ? _args[10] : "#ffffff";
50
- colorBorder = _args.length > 11 && _args[11] !== undefined ? _args[11] : "#000000";
51
- fontFamily = _args.length > 12 && _args[12] !== undefined ? _args[12] : "Arial";
52
- fontPath = _args.length > 13 && _args[13] !== undefined ? _args[13] : null;
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;
97
+ format = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : "PDF";
98
+ credentials = _args2.length > 6 && _args2[6] !== undefined ? _args2[6] : null;
99
+ colorFore = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : "#000000";
100
+ colorDots = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : "#000000";
101
+ colorSquare = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : "#000000";
102
+ colorBackground = _args2.length > 10 && _args2[10] !== undefined ? _args2[10] : "#ffffff";
103
+ colorBorder = _args2.length > 11 && _args2[11] !== undefined ? _args2[11] : "#000000";
104
+ fontFamily = _args2.length > 12 && _args2[12] !== undefined ? _args2[12] : "Arial";
105
+ fontPath = _args2.length > 13 && _args2[13] !== undefined ? _args2[13] : null;
106
+ fontColor = _args2.length > 14 && _args2[14] !== undefined ? _args2[14] : null;
107
+ rounded = _args2.length > 15 && _args2[15] !== undefined ? _args2[15] : false;
108
+ callback = _args2.length > 16 && _args2[16] !== undefined ? _args2[16] : null;
109
+ _context2.next = 14;
57
110
  return (0, _drive2["default"])(_drive, output, logo, {
58
111
  fore: colorFore,
59
112
  dots: colorDots,
@@ -66,19 +119,42 @@ var drive = exports.drive = /*#__PURE__*/function () {
66
119
  color: fontColor
67
120
  }, parseFloat(size), parseFloat(margin), rounded, format, credentials, callback);
68
121
  case 14:
69
- return _context.abrupt("return", _context.sent);
122
+ return _context2.abrupt("return", _context2.sent);
70
123
  case 15:
71
124
  case "end":
72
- return _context.stop();
125
+ return _context2.stop();
73
126
  }
74
- }, _callee);
127
+ }, _callee2);
75
128
  }));
76
- return function drive(_x, _x2, _x3, _x4, _x5) {
77
- return _ref.apply(this, arguments);
129
+ return function drive(_x3, _x4, _x5, _x6, _x7) {
130
+ return _ref2.apply(this, arguments);
78
131
  };
79
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
+ */
80
156
  var local = exports.local = /*#__PURE__*/function () {
81
- var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(drive, output, logo, size, margin) {
157
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(drive, output, logo, size, margin) {
82
158
  var format,
83
159
  credentials,
84
160
  colorFore,
@@ -91,23 +167,23 @@ var local = exports.local = /*#__PURE__*/function () {
91
167
  fontColor,
92
168
  rounded,
93
169
  callback,
94
- _args2 = arguments;
95
- return _regeneratorRuntime().wrap(function _callee2$(_context2) {
96
- while (1) switch (_context2.prev = _context2.next) {
170
+ _args3 = arguments;
171
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
172
+ while (1) switch (_context3.prev = _context3.next) {
97
173
  case 0:
98
- format = _args2.length > 5 && _args2[5] !== undefined ? _args2[5] : "PDF";
99
- credentials = _args2.length > 6 && _args2[6] !== undefined ? _args2[6] : null;
100
- colorFore = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : "#000000";
101
- colorDots = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : "#000000";
102
- colorSquare = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : "#000000";
103
- colorBackground = _args2.length > 10 && _args2[10] !== undefined ? _args2[10] : "#ffffff";
104
- colorBorder = _args2.length > 11 && _args2[11] !== undefined ? _args2[11] : "#000000";
105
- fontFamily = _args2.length > 12 && _args2[12] !== undefined ? _args2[12] : "Arial";
106
- fontPath = _args2.length > 13 && _args2[13] !== undefined ? _args2[13] : null;
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;
174
+ format = _args3.length > 5 && _args3[5] !== undefined ? _args3[5] : "PDF";
175
+ credentials = _args3.length > 6 && _args3[6] !== undefined ? _args3[6] : null;
176
+ colorFore = _args3.length > 7 && _args3[7] !== undefined ? _args3[7] : "#000000";
177
+ colorDots = _args3.length > 8 && _args3[8] !== undefined ? _args3[8] : "#000000";
178
+ colorSquare = _args3.length > 9 && _args3[9] !== undefined ? _args3[9] : "#000000";
179
+ colorBackground = _args3.length > 10 && _args3[10] !== undefined ? _args3[10] : "#ffffff";
180
+ colorBorder = _args3.length > 11 && _args3[11] !== undefined ? _args3[11] : "#000000";
181
+ fontFamily = _args3.length > 12 && _args3[12] !== undefined ? _args3[12] : "Arial";
182
+ fontPath = _args3.length > 13 && _args3[13] !== undefined ? _args3[13] : null;
183
+ fontColor = _args3.length > 14 && _args3[14] !== undefined ? _args3[14] : null;
184
+ rounded = _args3.length > 15 && _args3[15] !== undefined ? _args3[15] : false;
185
+ callback = _args3.length > 16 && _args3[16] !== undefined ? _args3[16] : null;
186
+ _context3.next = 14;
111
187
  return (0, _local["default"])(drive, output, logo, {
112
188
  fore: colorFore,
113
189
  dots: colorDots,
@@ -120,15 +196,15 @@ var local = exports.local = /*#__PURE__*/function () {
120
196
  color: fontColor
121
197
  }, parseFloat(size), parseFloat(margin), rounded, format, credentials, callback);
122
198
  case 14:
123
- return _context2.abrupt("return", _context2.sent);
199
+ return _context3.abrupt("return", _context3.sent);
124
200
  case 15:
125
201
  case "end":
126
- return _context2.stop();
202
+ return _context3.stop();
127
203
  }
128
- }, _callee2);
204
+ }, _callee3);
129
205
  }));
130
- return function local(_x6, _x7, _x8, _x9, _x10) {
131
- return _ref2.apply(this, arguments);
206
+ return function local(_x8, _x9, _x0, _x1, _x10) {
207
+ return _ref3.apply(this, arguments);
132
208
  };
133
209
  }();
134
210
  var _default = exports["default"] = {
@@ -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
+ }();
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pittica/drive-folder-qrcode",
3
3
  "private": false,
4
- "version": "1.4.1",
4
+ "version": "2.0.0",
5
5
  "description": "Creates QR codes from Google Drive folder names.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {
@@ -9,7 +9,8 @@
9
9
  "clean": "rimraf ./dist",
10
10
  "build": "npm run clean && mkdirp ./dist && babel src --out-dir ./dist --copy-files",
11
11
  "local": "npm run build && run-func dist/scripts.js local",
12
- "drive": "npm run build && run-func dist/scripts.js drive"
12
+ "drive": "npm run build && run-func dist/scripts.js drive",
13
+ "count": "npm run build && run-func dist/scripts.js count"
13
14
  },
14
15
  "repository": {
15
16
  "type": "git",
@@ -31,22 +32,22 @@
31
32
  "dependencies": {
32
33
  "@google-cloud/local-auth": "^3.0.1",
33
34
  "@svgdotjs/svg.js": "^3.2.4",
34
- "axios": "^1.7.8",
35
- "canvas": "^2.11.2",
35
+ "axios": "^1.9.0",
36
+ "canvas": "^3.1.0",
36
37
  "deasync": "^0.1.30",
37
- "googleapis": "^144.0.0",
38
- "jsdom": "^25.0.1",
38
+ "googleapis": "^149.0.0",
39
+ "jsdom": "^26.1.0",
39
40
  "memorystream": "^0.3.1",
40
- "qr-code-styling": "^1.8.4",
41
+ "qr-code-styling": "^1.9.2",
41
42
  "svg-to-pdfkit": "^0.1.8",
42
43
  "svgo": "^3.3.2"
43
44
  },
44
45
  "devDependencies": {
45
- "@babel/cli": "^7.25.9",
46
- "@babel/core": "^7.26.0",
47
- "@babel/preset-env": "^7.26.0",
46
+ "@babel/cli": "^7.27.2",
47
+ "@babel/core": "^7.27.1",
48
+ "@babel/preset-env": "^7.27.2",
48
49
  "mkdirp": "^3.0.1",
49
- "prettier": "^3.4.1",
50
+ "prettier": "^3.5.3",
50
51
  "rimraf": "^6.0.1",
51
52
  "run-func": "^3.0.0"
52
53
  }