@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/LICENSE +1 -1
- package/README.md +23 -1
- package/dist/drive/client.js +395 -10
- package/dist/generator/drive.js +9 -7
- package/dist/generator/generator.js +260 -0
- package/dist/generator/local.js +9 -7
- package/dist/index.js +4 -7
- package/dist/qrcode/extension/document.js +1 -1
- package/dist/qrcode/extension/fill-background.js +1 -1
- package/dist/qrcode/extension/fill-caption.js +1 -1
- package/dist/qrcode/extension/fill-margin.js +1 -1
- package/dist/qrcode/extension/get-background.js +1 -1
- package/dist/qrcode/extension/undef.js +1 -1
- package/dist/qrcode/extension.js +6 -6
- package/dist/{generator/pdf.js → qrcode/filename.js} +12 -15
- package/dist/qrcode/image.js +32 -12
- package/dist/qrcode/logo.js +144 -109
- package/dist/qrcode/window.js +1 -1
- package/dist/scripts.js +123 -47
- package/dist/settings/settings.js +184 -0
- package/package.json +12 -11
- package/dist/drive/folder.js +0 -347
- package/dist/generator/generate.js +0 -172
package/dist/qrcode/image.js
CHANGED
@@ -9,14 +9,15 @@ var _jsdom = require("jsdom");
|
|
9
9
|
var _canvas = _interopRequireDefault(require("canvas"));
|
10
10
|
var _deasync = require("deasync");
|
11
11
|
var _path = require("path");
|
12
|
+
var _svgToPdfkit = _interopRequireDefault(require("svg-to-pdfkit"));
|
13
|
+
var _pdfkit = _interopRequireDefault(require("pdfkit"));
|
12
14
|
var _fs = require("fs");
|
13
15
|
var _memorystream = _interopRequireDefault(require("memorystream"));
|
14
|
-
var _pdf2 = _interopRequireDefault(require("../generator/pdf"));
|
15
16
|
var _extension = _interopRequireDefault(require("./extension"));
|
16
|
-
var
|
17
|
+
var _filename2 = _interopRequireDefault(require("./filename"));
|
17
18
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
18
19
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
19
|
-
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/
|
20
|
+
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; }
|
20
21
|
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
21
22
|
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
22
23
|
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
@@ -24,7 +25,7 @@ function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o =
|
|
24
25
|
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
25
26
|
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
26
27
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
27
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); } // Copyright 2024 Pittica S.r.l.
|
28
|
+
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.
|
28
29
|
//
|
29
30
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
30
31
|
// you may not use this file except in compliance with the License.
|
@@ -42,6 +43,7 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
|
|
42
43
|
*/
|
43
44
|
var Image = exports["default"] = /*#__PURE__*/function () {
|
44
45
|
/**
|
46
|
+
* Creates a new instance of the Image class.
|
45
47
|
*
|
46
48
|
* @param {object} folder Google Drive input folder.
|
47
49
|
* @param {Number} size QR code size.
|
@@ -65,7 +67,8 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
65
67
|
var rounded = arguments.length > 7 && arguments[7] !== undefined ? arguments[7] : false;
|
66
68
|
var caption = arguments.length > 8 && arguments[8] !== undefined ? arguments[8] : null;
|
67
69
|
_classCallCheck(this, Image);
|
68
|
-
_defineProperty(this, "
|
70
|
+
_defineProperty(this, "_settings", {});
|
71
|
+
_defineProperty(this, "_qr", null);
|
69
72
|
this._settings = {
|
70
73
|
id: id,
|
71
74
|
name: name,
|
@@ -122,14 +125,31 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
122
125
|
return _createClass(Image, [{
|
123
126
|
key: "filename",
|
124
127
|
value: function filename(extension) {
|
125
|
-
return (0,
|
128
|
+
return (0, _filename2["default"])(this._settings, extension);
|
126
129
|
}
|
130
|
+
|
131
|
+
/**
|
132
|
+
* Writes a PDF file to the given stream.
|
133
|
+
*
|
134
|
+
* @param {WritableStream} stream Destination stream.
|
135
|
+
* @param {any} buffer Buffer containing SVG image.
|
136
|
+
* @param {function} callback Callback called at the end of the process.
|
137
|
+
* @returns {string|object} Callback output.
|
138
|
+
*/
|
127
139
|
}, {
|
128
140
|
key: "pdf",
|
129
141
|
value: function pdf(stream, buffer, callback) {
|
130
142
|
var lock = true;
|
131
143
|
var result = null;
|
132
|
-
var doc =
|
144
|
+
var doc = new _pdfkit["default"]({
|
145
|
+
compress: false,
|
146
|
+
size: [this._settings.size * 0.75, (this._settings.size + this._settings.margin * 2) * 0.75]
|
147
|
+
});
|
148
|
+
(0, _svgToPdfkit["default"])(doc, buffer.toString(), 0, 0, {
|
149
|
+
width: this._settings.size * 0.75,
|
150
|
+
height: (this._settings.size + this._settings.margin) * 0.75,
|
151
|
+
useCSS: false
|
152
|
+
});
|
133
153
|
doc.pipe(stream);
|
134
154
|
doc.once("end", function () {
|
135
155
|
if (typeof callback === "function") {
|
@@ -199,7 +219,7 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
199
219
|
*
|
200
220
|
* @param {string} output Google Drive output folder ID.
|
201
221
|
* @param {string} format Output format.
|
202
|
-
* @param {
|
222
|
+
* @param {Client} client Google Drive client.
|
203
223
|
* @returns {string} The destination ID.
|
204
224
|
*/
|
205
225
|
)
|
@@ -209,13 +229,13 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
209
229
|
var _upload = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(output) {
|
210
230
|
var _this2 = this;
|
211
231
|
var format,
|
212
|
-
|
232
|
+
client,
|
213
233
|
_args4 = arguments;
|
214
234
|
return _regeneratorRuntime().wrap(function _callee4$(_context4) {
|
215
235
|
while (1) switch (_context4.prev = _context4.next) {
|
216
236
|
case 0:
|
217
237
|
format = _args4.length > 1 && _args4[1] !== undefined ? _args4[1] : "PDF";
|
218
|
-
|
238
|
+
client = _args4.length > 2 ? _args4[2] : undefined;
|
219
239
|
_context4.next = 4;
|
220
240
|
return this._qr.getRawData("svg").then(/*#__PURE__*/function () {
|
221
241
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(buffer) {
|
@@ -238,7 +258,7 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
238
258
|
case 0:
|
239
259
|
queue = _ref5.queue;
|
240
260
|
_context2.next = 3;
|
241
|
-
return
|
261
|
+
return client.uploadFile(output, Buffer.concat(queue).toString(), _this2.filename(format), "application/pdf");
|
242
262
|
case 3:
|
243
263
|
return _context2.abrupt("return", _context2.sent);
|
244
264
|
case 4:
|
@@ -255,7 +275,7 @@ var Image = exports["default"] = /*#__PURE__*/function () {
|
|
255
275
|
return _context3.abrupt("return", file);
|
256
276
|
case 7:
|
257
277
|
_context3.next = 9;
|
258
|
-
return
|
278
|
+
return client.uploadFile(output, buffer.toString(), _this2.filename(format), "image/svg+xml");
|
259
279
|
case 9:
|
260
280
|
return _context3.abrupt("return", _context3.sent);
|
261
281
|
case 10:
|
package/dist/qrcode/logo.js
CHANGED
@@ -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
|
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
|
12
|
+
var _window2 = _interopRequireDefault(require("./window"));
|
14
13
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
15
|
-
function
|
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); }); }; }
|
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
|
-
*
|
32
|
-
*
|
33
|
-
* @param {string} file File path or URL.
|
34
|
-
* @returns {Output} The logo content.
|
37
|
+
* Logo class and helpers.
|
35
38
|
*/
|
36
|
-
var
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
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
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
}
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
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
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
}
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
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
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
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/qrcode/window.js
CHANGED
@@ -5,7 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
});
|
6
6
|
exports["default"] = void 0;
|
7
7
|
var _jsdom = require("jsdom");
|
8
|
-
// Copyright 2024 Pittica S.r.l.
|
8
|
+
// Copyright 2024-2025 Pittica S.r.l.
|
9
9
|
//
|
10
10
|
// Licensed under the Apache License, Version 2.0 (the "License");
|
11
11
|
// you may not use this file except in compliance with the License.
|