@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/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/
|
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
|
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
|
-
|
41
|
-
return _regeneratorRuntime().wrap(function
|
42
|
-
while (1) switch (
|
93
|
+
_args2 = arguments;
|
94
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
95
|
+
while (1) switch (_context2.prev = _context2.next) {
|
43
96
|
case 0:
|
44
|
-
format =
|
45
|
-
credentials =
|
46
|
-
colorFore =
|
47
|
-
colorDots =
|
48
|
-
colorSquare =
|
49
|
-
colorBackground =
|
50
|
-
colorBorder =
|
51
|
-
fontFamily =
|
52
|
-
fontPath =
|
53
|
-
fontColor =
|
54
|
-
rounded =
|
55
|
-
callback =
|
56
|
-
|
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
|
122
|
+
return _context2.abrupt("return", _context2.sent);
|
70
123
|
case 15:
|
71
124
|
case "end":
|
72
|
-
return
|
125
|
+
return _context2.stop();
|
73
126
|
}
|
74
|
-
},
|
127
|
+
}, _callee2);
|
75
128
|
}));
|
76
|
-
return function drive(
|
77
|
-
return
|
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
|
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
|
-
|
95
|
-
return _regeneratorRuntime().wrap(function
|
96
|
-
while (1) switch (
|
170
|
+
_args3 = arguments;
|
171
|
+
return _regeneratorRuntime().wrap(function _callee3$(_context3) {
|
172
|
+
while (1) switch (_context3.prev = _context3.next) {
|
97
173
|
case 0:
|
98
|
-
format =
|
99
|
-
credentials =
|
100
|
-
colorFore =
|
101
|
-
colorDots =
|
102
|
-
colorSquare =
|
103
|
-
colorBackground =
|
104
|
-
colorBorder =
|
105
|
-
fontFamily =
|
106
|
-
fontPath =
|
107
|
-
fontColor =
|
108
|
-
rounded =
|
109
|
-
callback =
|
110
|
-
|
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
|
199
|
+
return _context3.abrupt("return", _context3.sent);
|
124
200
|
case 15:
|
125
201
|
case "end":
|
126
|
-
return
|
202
|
+
return _context3.stop();
|
127
203
|
}
|
128
|
-
},
|
204
|
+
}, _callee3);
|
129
205
|
}));
|
130
|
-
return function local(
|
131
|
-
return
|
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": "
|
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.
|
35
|
-
"canvas": "^
|
35
|
+
"axios": "^1.9.0",
|
36
|
+
"canvas": "^3.1.0",
|
36
37
|
"deasync": "^0.1.30",
|
37
|
-
"googleapis": "^
|
38
|
-
"jsdom": "^
|
38
|
+
"googleapis": "^149.0.0",
|
39
|
+
"jsdom": "^26.1.0",
|
39
40
|
"memorystream": "^0.3.1",
|
40
|
-
"qr-code-styling": "^1.
|
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.
|
46
|
-
"@babel/core": "^7.
|
47
|
-
"@babel/preset-env": "^7.
|
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.
|
50
|
+
"prettier": "^3.5.3",
|
50
51
|
"rimraf": "^6.0.1",
|
51
52
|
"run-func": "^3.0.0"
|
52
53
|
}
|