@pittica/drive-folder-qrcode 1.2.5 → 1.3.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.
@@ -47,10 +47,14 @@ var _default = exports["default"] = /*#__PURE__*/function () {
47
47
  })["catch"](function (_ref3) {
48
48
  var code = _ref3.code,
49
49
  errors = _ref3.errors;
50
- errors.forEach(function (_ref4) {
51
- var message = _ref4.message;
52
- return console.error(code, message);
53
- });
50
+ if (errors) {
51
+ errors.forEach(function (_ref4) {
52
+ var message = _ref4.message;
53
+ return console.error(code, message);
54
+ });
55
+ } else {
56
+ console.error(code);
57
+ }
54
58
  return null;
55
59
  });
56
60
  case 4:
@@ -27,18 +27,20 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
27
27
  // limitations under the License.
28
28
  var _default = exports["default"] = /*#__PURE__*/function () {
29
29
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(drive, output, logo, colors, font, size, margin) {
30
- var format,
30
+ var rounded,
31
+ format,
31
32
  credentials,
32
33
  images,
33
34
  _args2 = arguments;
34
35
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
35
36
  while (1) switch (_context2.prev = _context2.next) {
36
37
  case 0:
37
- format = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : "PDF";
38
- credentials = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : null;
39
- _context2.next = 4;
40
- return (0, _generate["default"])(drive, logo, colors, font, size, margin, credentials);
41
- case 4:
38
+ rounded = _args2.length > 7 && _args2[7] !== undefined ? _args2[7] : false;
39
+ format = _args2.length > 8 && _args2[8] !== undefined ? _args2[8] : "PDF";
40
+ credentials = _args2.length > 9 && _args2[9] !== undefined ? _args2[9] : null;
41
+ _context2.next = 5;
42
+ return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials);
43
+ case 5:
42
44
  images = _context2.sent;
43
45
  images.forEach(function (_ref2) {
44
46
  var _ref2$folder = _ref2.folder,
@@ -75,7 +77,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
75
77
  }
76
78
  });
77
79
  });
78
- case 6:
80
+ case 7:
79
81
  case "end":
80
82
  return _context2.stop();
81
83
  }
@@ -26,26 +26,28 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
26
26
  // limitations under the License.
27
27
  var _default = exports["default"] = /*#__PURE__*/function () {
28
28
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, logo, colors, font, size, margin) {
29
- var credentials,
29
+ var rounded,
30
+ credentials,
30
31
  data,
31
32
  folders,
32
33
  _args = arguments;
33
34
  return _regeneratorRuntime().wrap(function _callee$(_context) {
34
35
  while (1) switch (_context.prev = _context.next) {
35
36
  case 0:
36
- credentials = _args.length > 6 && _args[6] !== undefined ? _args[6] : null;
37
- _context.next = 3;
37
+ rounded = _args.length > 6 && _args[6] !== undefined ? _args[6] : false;
38
+ credentials = _args.length > 7 && _args[7] !== undefined ? _args[7] : null;
39
+ _context.next = 4;
38
40
  return (0, _logo.getContent)(logo);
39
- case 3:
41
+ case 4:
40
42
  data = _context.sent;
41
- _context.next = 6;
43
+ _context.next = 7;
42
44
  return (0, _folder.list)(drive, credentials);
43
- case 6:
45
+ case 7:
44
46
  folders = _context.sent;
45
47
  console.info("Processing \"".concat(drive, "\"..."));
46
48
  return _context.abrupt("return", folders.map(function (folder) {
47
49
  try {
48
- var qr = (0, _image["default"])(folder, size, margin, logo, data ? (0, _logo.resize)(data, size) : null, colors, font);
50
+ var qr = (0, _image["default"])(folder, size, margin, logo, data ? (0, _logo.resize)(data, size) : null, colors, font, rounded);
49
51
  console.info("Creating QR code for \"".concat(folder.name, "\"."));
50
52
  return {
51
53
  folder: folder,
@@ -55,7 +57,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
55
57
  console.error("Error creating QR code for \"".concat(folder.name, "\"."));
56
58
  }
57
59
  }));
58
- case 9:
60
+ case 10:
59
61
  case "end":
60
62
  return _context.stop();
61
63
  }
@@ -27,18 +27,20 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
27
27
  // limitations under the License.
28
28
  var _default = exports["default"] = /*#__PURE__*/function () {
29
29
  var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, output, logo, colors, font, size, margin) {
30
- var format,
30
+ var rounded,
31
+ format,
31
32
  credentials,
32
33
  images,
33
34
  _args = arguments;
34
35
  return _regeneratorRuntime().wrap(function _callee$(_context) {
35
36
  while (1) switch (_context.prev = _context.next) {
36
37
  case 0:
37
- format = _args.length > 7 && _args[7] !== undefined ? _args[7] : "PDF";
38
- credentials = _args.length > 8 && _args[8] !== undefined ? _args[8] : null;
39
- _context.next = 4;
40
- return (0, _generate["default"])(drive, logo, colors, font, size, margin, credentials);
41
- case 4:
38
+ rounded = _args.length > 7 && _args[7] !== undefined ? _args[7] : false;
39
+ format = _args.length > 8 && _args[8] !== undefined ? _args[8] : "PDF";
40
+ credentials = _args.length > 9 && _args[9] !== undefined ? _args[9] : null;
41
+ _context.next = 5;
42
+ return (0, _generate["default"])(drive, logo, colors, font, size, margin, rounded, credentials);
43
+ case 5:
42
44
  images = _context.sent;
43
45
  images.forEach(function (_ref2) {
44
46
  var _ref2$folder = _ref2.folder,
@@ -59,7 +61,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
59
61
  }
60
62
  });
61
63
  });
62
- case 6:
64
+ case 7:
63
65
  case "end":
64
66
  return _context.stop();
65
67
  }
@@ -17,8 +17,8 @@ exports["default"] = void 0;
17
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
18
  // See the License for the specific language governing permissions and
19
19
  // limitations under the License.
20
- var _default = exports["default"] = function _default(context, width, height, margin, color) {
20
+ var _default = exports["default"] = function _default(context, width, height, margin, color, rounded) {
21
21
  context.fillStyle = color;
22
- context.roundRect(1, 1, width - 2, height + margin * 2 - 2, margin);
22
+ context.roundRect(1, 1, width - 2, height + margin * 2 - 2, rounded ? margin : 0);
23
23
  context.fill();
24
24
  };
@@ -17,10 +17,10 @@ exports["default"] = void 0;
17
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18
18
  // See the License for the specific language governing permissions and
19
19
  // limitations under the License.
20
- var _default = exports["default"] = function _default(context, width, height, margin, color) {
20
+ var _default = exports["default"] = function _default(context, width, height, margin, color, rounded) {
21
21
  var over = margin * 2;
22
22
  context.fillStyle = color;
23
- context.roundRect(0, 0, width, height + over, margin);
24
- context.roundRect(margin, margin, width - over, height - over, margin);
23
+ context.roundRect(0, 0, width, height + over, rounded ? margin : 0);
24
+ context.roundRect(margin, margin, width - over, height - over, rounded ? margin : 0);
25
25
  context.fill("evenodd");
26
26
  };
@@ -20,9 +20,9 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
20
20
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
21
  // See the License for the specific language governing permissions and
22
22
  // limitations under the License.
23
- var _default = exports["default"] = function _default(createCanvas, width, height, margin, color) {
23
+ var _default = exports["default"] = function _default(createCanvas, width, height, margin, color, rounded) {
24
24
  var canvas = createCanvas(width, height + margin, "svg");
25
25
  var context = canvas.getContext("2d");
26
- (0, _fillBackground["default"])(context, width, height, margin, color);
26
+ (0, _fillBackground["default"])(context, width, height, margin, color, rounded);
27
27
  return (0, _document["default"])(canvas.toBuffer().toString());
28
28
  };
@@ -12,6 +12,7 @@ var _fillCaption = _interopRequireDefault(require("./extension/fill-caption"));
12
12
  var _fillMargin = _interopRequireDefault(require("./extension/fill-margin"));
13
13
  var _document = _interopRequireDefault(require("./extension/document"));
14
14
  var _undef = _interopRequireDefault(require("./extension/undef"));
15
+ var _svg = require("@svgdotjs/svg.js");
15
16
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
17
  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; }
17
18
  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); }
@@ -30,12 +31,12 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
30
31
  // limitations under the License.
31
32
  var _default = exports["default"] = /*#__PURE__*/function () {
32
33
  var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(svg, _ref) {
33
- var _ref$nodeCanvas, createCanvas, registerFont, width, height, margin, caption, image, logo, backgroundOptions, borderOptions, font, bg, canvas, context, frame, elements, images, h, _optimize, data, optimized, background;
34
+ var _ref$nodeCanvas, createCanvas, registerFont, width, height, margin, caption, image, logo, backgroundOptions, borderOptions, font, rounded, bg, canvas, context, frame, elements, images, h, _optimize, data, optimized, background;
34
35
  return _regeneratorRuntime().wrap(function _callee$(_context) {
35
36
  while (1) switch (_context.prev = _context.next) {
36
37
  case 0:
37
- _ref$nodeCanvas = _ref.nodeCanvas, createCanvas = _ref$nodeCanvas.createCanvas, registerFont = _ref$nodeCanvas.registerFont, width = _ref.width, height = _ref.height, margin = _ref.margin, caption = _ref.caption, image = _ref.image, logo = _ref.logo, backgroundOptions = _ref.backgroundOptions, borderOptions = _ref.borderOptions, font = _ref.font;
38
- if (font.path) {
38
+ _ref$nodeCanvas = _ref.nodeCanvas, createCanvas = _ref$nodeCanvas.createCanvas, registerFont = _ref$nodeCanvas.registerFont, width = _ref.width, height = _ref.height, margin = _ref.margin, caption = _ref.caption, image = _ref.image, logo = _ref.logo, backgroundOptions = _ref.backgroundOptions, borderOptions = _ref.borderOptions, font = _ref.font, rounded = _ref.rounded;
39
+ if (font.path && font.family) {
39
40
  registerFont(font.path, {
40
41
  family: font.family
41
42
  });
@@ -44,8 +45,8 @@ var _default = exports["default"] = /*#__PURE__*/function () {
44
45
  bg.parentElement.removeChild(bg);
45
46
  canvas = createCanvas(width, height + margin, "svg");
46
47
  context = canvas.getContext("2d");
47
- (0, _fillMargin["default"])(context, width, height, margin, borderOptions.color);
48
- context.font = "".concat(margin, "px \"").concat(font.family, "\"");
48
+ (0, _fillMargin["default"])(context, width, height, margin, borderOptions.color, rounded);
49
+ context.font = font.family ? "".concat(margin, "px \"").concat(font.family, "\"") : "".concat(margin, "px");
49
50
  context.fillStyle = backgroundOptions.color;
50
51
  (0, _fillCaption["default"])(caption.toUpperCase(), context, canvas, margin);
51
52
  frame = (0, _document["default"])(canvas.toBuffer().toString());
@@ -64,7 +65,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
64
65
  plugins: ["collapseGroups", "convertColors", "inlineStyles", "removeUselessDefs", "removeUselessStrokeAndFill", "removeComments", "mergePaths", "convertPathData", "convertStyleToAttrs", "removeEmptyContainers"]
65
66
  }), data = _optimize.data;
66
67
  optimized = (0, _document["default"])(data);
67
- background = (0, _getBackground["default"])(createCanvas, width, height, margin, backgroundOptions.color);
68
+ background = (0, _getBackground["default"])(createCanvas, width, height, margin, backgroundOptions.color, rounded);
68
69
  svg.innerHTML = background.querySelector("svg").innerHTML + optimized.getElementsByTagName("svg")[0].innerHTML;
69
70
  case 22:
70
71
  case "end":
@@ -30,6 +30,7 @@ var _default = exports["default"] = function _default(_ref, size, margin, image,
30
30
  square = _ref2.square,
31
31
  background = _ref2.background,
32
32
  border = _ref2.border;
33
+ var rounded = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
33
34
  var qr = new _qrCodeStyling["default"]({
34
35
  jsdom: _jsdom.JSDOM,
35
36
  nodeCanvas: _canvas["default"],
@@ -41,15 +42,15 @@ var _default = exports["default"] = function _default(_ref, size, margin, image,
41
42
  image: image,
42
43
  dotsOptions: {
43
44
  color: fore,
44
- type: "dots"
45
+ type: rounded ? "dots" : "square"
45
46
  },
46
47
  cornersDotOptions: {
47
48
  color: dots,
48
- type: "dot"
49
+ type: rounded ? "dot" : "square"
49
50
  },
50
51
  cornersSquareOptions: {
51
52
  color: square,
52
- type: "extra-rounded"
53
+ type: rounded ? "extra-rounded" : "square"
53
54
  },
54
55
  backgroundOptions: {
55
56
  color: background
@@ -64,7 +65,8 @@ var _default = exports["default"] = function _default(_ref, size, margin, image,
64
65
  },
65
66
  caption: name,
66
67
  logo: logo,
67
- font: font
68
+ font: font,
69
+ rounded: rounded
68
70
  });
69
71
  qr.applyExtension(_extension["default"]);
70
72
  return qr;
@@ -1,10 +1,10 @@
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); }
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
- exports.getContent = getContent;
7
- exports.resize = resize;
7
+ exports.resize = exports.getFile = exports.getContent = void 0;
8
8
  var _svgo = require("svgo");
9
9
  var _axios = _interopRequireDefault(require("axios"));
10
10
  var _svg = require("@svgdotjs/svg.js");
@@ -12,7 +12,6 @@ var _url = require("url");
12
12
  var _fs = _interopRequireDefault(require("fs"));
13
13
  var _window = _interopRequireDefault(require("./window"));
14
14
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
15
- 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); }
16
15
  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; }
17
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); }
18
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 Pittica S.r.l.
@@ -28,12 +27,15 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
28
27
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
29
28
  // See the License for the specific language governing permissions and
30
29
  // limitations under the License.
31
- function getContent(_x) {
32
- return _getContent.apply(this, arguments);
33
- }
34
- function _getContent() {
35
- _getContent = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(file) {
36
- var url, protocol, _yield$axios$get$then, data, _optimize, _data, _optimize2, _data2;
30
+ /**
31
+ * Gets the logo content.
32
+ *
33
+ * @param {string} file File path or URL.
34
+ * @returns {Output} The logo content.
35
+ */
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;
37
39
  return _regeneratorRuntime().wrap(function _callee$(_context) {
38
40
  while (1) switch (_context.prev = _context.next) {
39
41
  case 0:
@@ -45,8 +47,8 @@ function _getContent() {
45
47
  break;
46
48
  }
47
49
  _context.next = 6;
48
- return _axios["default"].get(url).then(function (_ref) {
49
- var data = _ref.data;
50
+ return _axios["default"].get(url).then(function (_ref2) {
51
+ var data = _ref2.data;
50
52
  return (0, _svgo.optimize)(data);
51
53
  });
52
54
  case 6:
@@ -54,25 +56,49 @@ function _getContent() {
54
56
  data = _yield$axios$get$then.data;
55
57
  return _context.abrupt("return", data);
56
58
  case 11:
57
- _optimize = (0, _svgo.optimize)(_fs["default"].readFileSync(file)), _data = _optimize.data;
58
- return _context.abrupt("return", _data);
59
- case 13:
60
- _context.next = 19;
59
+ return _context.abrupt("return", getFile(file));
60
+ case 12:
61
+ _context.next = 17;
61
62
  break;
62
- case 15:
63
- _context.prev = 15;
63
+ case 14:
64
+ _context.prev = 14;
64
65
  _context.t0 = _context["catch"](0);
65
- _optimize2 = (0, _svgo.optimize)(_fs["default"].readFileSync(file)), _data2 = _optimize2.data;
66
- return _context.abrupt("return", _data2);
67
- case 19:
66
+ return _context.abrupt("return", getFile(file));
67
+ case 17:
68
68
  case "end":
69
69
  return _context.stop();
70
70
  }
71
- }, _callee, null, [[0, 15]]);
71
+ }, _callee, null, [[0, 14]]);
72
72
  }));
73
- return _getContent.apply(this, arguments);
74
- }
75
- function resize(data, size) {
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
+ * @returns {string} File content from the given file path
83
+ */
84
+ var getFile = exports.getFile = function getFile(file) {
85
+ try {
86
+ var _optimize = (0, _svgo.optimize)(_fs["default"].readFileSync(file)),
87
+ data = _optimize.data;
88
+ return data;
89
+ } catch (_unused) {
90
+ return null;
91
+ }
92
+ };
93
+
94
+ /**
95
+ * Resizes a logo from the given data.
96
+ *
97
+ * @param {string} data SVG data.
98
+ * @param {Number} size Greather side size of the logo.
99
+ * @returns Resized logo.
100
+ */
101
+ var resize = exports.resize = function resize(data, size) {
76
102
  var win = (0, _window["default"])(data);
77
103
  (0, _svg.registerWindow)(win, win.document);
78
104
  var svg = (0, _svg.SVG)(data);
@@ -81,4 +107,4 @@ function resize(data, size) {
81
107
  svg.size(width, width);
82
108
  svg.move(x, x);
83
109
  return svg.xml();
84
- }
110
+ };
package/dist/scripts.js CHANGED
@@ -34,6 +34,7 @@ var drive = exports.drive = /*#__PURE__*/function () {
34
34
  colorBorder,
35
35
  fontFamily,
36
36
  fontPath,
37
+ rounded,
37
38
  _args = arguments;
38
39
  return _regeneratorRuntime().wrap(function _callee$(_context) {
39
40
  while (1) switch (_context.prev = _context.next) {
@@ -47,7 +48,8 @@ var drive = exports.drive = /*#__PURE__*/function () {
47
48
  colorBorder = _args.length > 11 && _args[11] !== undefined ? _args[11] : "#000000";
48
49
  fontFamily = _args.length > 12 && _args[12] !== undefined ? _args[12] : "Arial";
49
50
  fontPath = _args.length > 13 && _args[13] !== undefined ? _args[13] : null;
50
- _context.next = 11;
51
+ rounded = _args.length > 14 && _args[14] !== undefined ? _args[14] : true;
52
+ _context.next = 12;
51
53
  return (0, _drive2["default"])(_drive, output, logo, {
52
54
  fore: colorFore,
53
55
  dots: colorDots,
@@ -57,10 +59,10 @@ var drive = exports.drive = /*#__PURE__*/function () {
57
59
  }, {
58
60
  path: fontPath,
59
61
  family: fontFamily
60
- }, parseFloat(size), parseFloat(margin), format, credentials);
61
- case 11:
62
- return _context.abrupt("return", _context.sent);
62
+ }, parseFloat(size), parseFloat(margin), rounded, format, credentials);
63
63
  case 12:
64
+ return _context.abrupt("return", _context.sent);
65
+ case 13:
64
66
  case "end":
65
67
  return _context.stop();
66
68
  }
@@ -81,6 +83,7 @@ var local = exports.local = /*#__PURE__*/function () {
81
83
  colorBorder,
82
84
  fontFamily,
83
85
  fontPath,
86
+ rounded,
84
87
  _args2 = arguments;
85
88
  return _regeneratorRuntime().wrap(function _callee2$(_context2) {
86
89
  while (1) switch (_context2.prev = _context2.next) {
@@ -94,7 +97,8 @@ var local = exports.local = /*#__PURE__*/function () {
94
97
  colorBorder = _args2.length > 11 && _args2[11] !== undefined ? _args2[11] : "#000000";
95
98
  fontFamily = _args2.length > 12 && _args2[12] !== undefined ? _args2[12] : "Arial";
96
99
  fontPath = _args2.length > 13 && _args2[13] !== undefined ? _args2[13] : null;
97
- _context2.next = 11;
100
+ rounded = _args2.length > 14 && _args2[14] !== undefined ? _args2[14] : false;
101
+ _context2.next = 12;
98
102
  return (0, _local["default"])(drive, output, logo, {
99
103
  fore: colorFore,
100
104
  dots: colorDots,
@@ -104,10 +108,10 @@ var local = exports.local = /*#__PURE__*/function () {
104
108
  }, {
105
109
  path: fontPath,
106
110
  family: fontFamily
107
- }, parseFloat(size), parseFloat(margin), format, credentials);
108
- case 11:
109
- return _context2.abrupt("return", _context2.sent);
111
+ }, parseFloat(size), parseFloat(margin), rounded, format, credentials);
110
112
  case 12:
113
+ return _context2.abrupt("return", _context2.sent);
114
+ case 13:
111
115
  case "end":
112
116
  return _context2.stop();
113
117
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@pittica/drive-folder-qrcode",
3
3
  "private": false,
4
- "version": "1.2.5",
4
+ "version": "1.3.0",
5
5
  "description": "Creates QR codes from Google Drive folder names.",
6
6
  "main": "dist/index.js",
7
7
  "scripts": {