@pittica/drive-folder-qrcode 1.5.1 → 2.1.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.
@@ -0,0 +1,346 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = void 0;
7
+ var _client = _interopRequireDefault(require("../drive/client"));
8
+ var _settings = _interopRequireDefault(require("../settings/settings"));
9
+ var _image = _interopRequireDefault(require("../qrcode/image"));
10
+ var _logo = _interopRequireDefault(require("../qrcode/logo"));
11
+ var _filename = _interopRequireDefault(require("../qrcode/filename"));
12
+ var _path = require("path");
13
+ var _fs = require("fs");
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
+ function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
17
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
18
+ function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
19
+ function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
20
+ function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
21
+ function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
22
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
23
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
24
+ function _OverloadYield(e, d) { this.v = e, this.k = d; }
25
+ 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); }
26
+ 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); }); }; }
27
+ function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
28
+ 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); } }
29
+ function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
30
+ 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; }
31
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
32
+ 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.
33
+ //
34
+ // Licensed under the Apache License, Version 2.0 (the "License");
35
+ // you may not use this file except in compliance with the License.
36
+ // You may obtain a copy of the License at
37
+ //
38
+ // http://www.apache.org/licenses/LICENSE-2.0
39
+ //
40
+ // Unless required by applicable law or agreed to in writing, software
41
+ // distributed under the License is distributed on an "AS IS" BASIS,
42
+ // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
43
+ // See the License for the specific language governing permissions and
44
+ // limitations under the License.
45
+ /**
46
+ * Generator.
47
+ */
48
+ var Generator = exports["default"] = /*#__PURE__*/function () {
49
+ /**
50
+ * Creates a new instance of the Generator class.
51
+ *
52
+ * @param {string|object|null} credentials Credentials object or JSON file path.
53
+ * @param {string|null} file Settings file path.
54
+ * @param {object} settings Settings data.
55
+ */
56
+ function Generator() {
57
+ var credentials = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : null;
58
+ var file = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : null;
59
+ var settings = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
60
+ _classCallCheck(this, Generator);
61
+ _defineProperty(this, "_client", null);
62
+ _defineProperty(this, "_settings", new _settings["default"]());
63
+ this._client = new _client["default"](credentials);
64
+ this._settings = new _settings["default"](file);
65
+ this._settings.merge(settings);
66
+ }
67
+
68
+ /**
69
+ * Generates graphics.
70
+ *
71
+ * @param {string} logo Logo image path.
72
+ * @param {function} captionCallback Caption text filter.
73
+ * @returns {boolean} A value indicating whether the file has been created.
74
+ */
75
+ return _createClass(Generator, [{
76
+ key: "generate",
77
+ value: (function () {
78
+ var _generate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(logo) {
79
+ var captionCallback,
80
+ result,
81
+ source,
82
+ _this$_settings$getSe,
83
+ size,
84
+ image,
85
+ data,
86
+ folders,
87
+ _args = arguments;
88
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
89
+ while (1) switch (_context.prev = _context.next) {
90
+ case 0:
91
+ captionCallback = _args.length > 1 && _args[1] !== undefined ? _args[1] : null;
92
+ result = [];
93
+ source = this._settings.getSource();
94
+ _this$_settings$getSe = this._settings.getSettings(), size = _this$_settings$getSe.size;
95
+ if (!source) {
96
+ _context.next = 17;
97
+ break;
98
+ }
99
+ image = new _logo["default"](logo);
100
+ _context.next = 8;
101
+ return image.getData(size);
102
+ case 8:
103
+ data = _context.sent;
104
+ _context.next = 11;
105
+ return this._client.list(source);
106
+ case 11:
107
+ folders = _context.sent;
108
+ console.info("Processing \"".concat(source, "\"..."));
109
+ _context.next = 15;
110
+ return this.process(folders, logo, data, captionCallback, result);
111
+ case 15:
112
+ _context.next = 18;
113
+ break;
114
+ case 17:
115
+ console.error("Source Google Drive or folder is required.");
116
+ case 18:
117
+ return _context.abrupt("return", result);
118
+ case 19:
119
+ case "end":
120
+ return _context.stop();
121
+ }
122
+ }, _callee, this);
123
+ }));
124
+ function generate(_x) {
125
+ return _generate.apply(this, arguments);
126
+ }
127
+ return generate;
128
+ }()
129
+ /**
130
+ * Indicates whether the file exists in the output folder.
131
+ *
132
+ * @param {object} folder Output folder ID.
133
+ * @returns {boolean} A value indicating whether the file exists in the output folder.
134
+ */
135
+ )
136
+ }, {
137
+ key: "existsDrive",
138
+ value: (function () {
139
+ var _existsDrive = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee2(folder) {
140
+ var _this$_settings$getDe, drive;
141
+ return _regeneratorRuntime().wrap(function _callee2$(_context2) {
142
+ while (1) switch (_context2.prev = _context2.next) {
143
+ case 0:
144
+ _this$_settings$getDe = this._settings.getDestination(), drive = _this$_settings$getDe.drive;
145
+ if (!drive) {
146
+ _context2.next = 5;
147
+ break;
148
+ }
149
+ _context2.next = 4;
150
+ return this._client.hasFile(drive, (0, _filename["default"])(folder, this._settings.getSettings().format));
151
+ case 4:
152
+ return _context2.abrupt("return", _context2.sent);
153
+ case 5:
154
+ return _context2.abrupt("return", false);
155
+ case 6:
156
+ case "end":
157
+ return _context2.stop();
158
+ }
159
+ }, _callee2, this);
160
+ }));
161
+ function existsDrive(_x2) {
162
+ return _existsDrive.apply(this, arguments);
163
+ }
164
+ return existsDrive;
165
+ }()
166
+ /**
167
+ * Indicates whether the file exists in the output folder.
168
+ *
169
+ * @param {object} folder Output folder name.
170
+ * @returns {boolean} A value indicating whether the file exists in the output folder.
171
+ */
172
+ )
173
+ }, {
174
+ key: "existsLocal",
175
+ value: (function () {
176
+ var _existsLocal = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee3(folder) {
177
+ var _this$_settings$getDe2, local;
178
+ return _regeneratorRuntime().wrap(function _callee3$(_context3) {
179
+ while (1) switch (_context3.prev = _context3.next) {
180
+ case 0:
181
+ _this$_settings$getDe2 = this._settings.getDestination(), local = _this$_settings$getDe2.local;
182
+ if (!local) {
183
+ _context3.next = 3;
184
+ break;
185
+ }
186
+ return _context3.abrupt("return", (0, _fs.existsSync)((0, _path.join)(local, (0, _filename["default"])(folder, this._settings.getSettings().format))));
187
+ case 3:
188
+ return _context3.abrupt("return", false);
189
+ case 4:
190
+ case "end":
191
+ return _context3.stop();
192
+ }
193
+ }, _callee3, this);
194
+ }));
195
+ function existsLocal(_x3) {
196
+ return _existsLocal.apply(this, arguments);
197
+ }
198
+ return existsLocal;
199
+ }()
200
+ /**
201
+ * Indicates whether the file related to the given folder needs an update.
202
+ *
203
+ * @param {object} folder Output folder name.
204
+ * @returns {boolean} A value indicating whether the file related to the given folder needs an update.
205
+ */
206
+ )
207
+ }, {
208
+ key: "needsUpate",
209
+ value: (function () {
210
+ var _needsUpate = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee4(folder) {
211
+ var _this$_settings$getDe3, local, drive;
212
+ return _regeneratorRuntime().wrap(function _callee4$(_context4) {
213
+ while (1) switch (_context4.prev = _context4.next) {
214
+ case 0:
215
+ _this$_settings$getDe3 = this._settings.getDestination(), local = _this$_settings$getDe3.local, drive = _this$_settings$getDe3.drive;
216
+ _context4.t1 = drive;
217
+ if (!_context4.t1) {
218
+ _context4.next = 6;
219
+ break;
220
+ }
221
+ _context4.next = 5;
222
+ return this.existsDrive(folder);
223
+ case 5:
224
+ _context4.t1 = !_context4.sent;
225
+ case 6:
226
+ _context4.t0 = _context4.t1;
227
+ if (_context4.t0) {
228
+ _context4.next = 14;
229
+ break;
230
+ }
231
+ _context4.t2 = local;
232
+ if (!_context4.t2) {
233
+ _context4.next = 13;
234
+ break;
235
+ }
236
+ _context4.next = 12;
237
+ return this.existsLocal(folder);
238
+ case 12:
239
+ _context4.t2 = !_context4.sent;
240
+ case 13:
241
+ _context4.t0 = _context4.t2;
242
+ case 14:
243
+ return _context4.abrupt("return", _context4.t0);
244
+ case 15:
245
+ case "end":
246
+ return _context4.stop();
247
+ }
248
+ }, _callee4, this);
249
+ }));
250
+ function needsUpate(_x4) {
251
+ return _needsUpate.apply(this, arguments);
252
+ }
253
+ return needsUpate;
254
+ }()
255
+ /**
256
+ * Processes the folder data.
257
+ *
258
+ * @param {Array} folders An array of folder paths or IDs.
259
+ * @param {string} image Logo path.
260
+ * @param {string} data Logo image data.
261
+ * @param {function} captionCallback Caption text filter.
262
+ * @param {Array} result An array of folder paths or IDs containing the created files.
263
+ * @param {number} index Folders index.
264
+ */
265
+ )
266
+ }, {
267
+ key: "process",
268
+ value: (function () {
269
+ var _process = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee5(folders, logo, data, captionCallback, result) {
270
+ var index,
271
+ folder,
272
+ _this$_settings$getSe2,
273
+ size,
274
+ margin,
275
+ rounded,
276
+ format,
277
+ _this$_settings$getDe4,
278
+ local,
279
+ drive,
280
+ qr,
281
+ _args5 = arguments;
282
+ return _regeneratorRuntime().wrap(function _callee5$(_context5) {
283
+ while (1) switch (_context5.prev = _context5.next) {
284
+ case 0:
285
+ index = _args5.length > 5 && _args5[5] !== undefined ? _args5[5] : 0;
286
+ if (!(typeof folders[index] !== "undefined")) {
287
+ _context5.next = 30;
288
+ break;
289
+ }
290
+ folder = folders[index];
291
+ _context5.prev = 3;
292
+ _context5.next = 6;
293
+ return this.needsUpate(folder);
294
+ case 6:
295
+ if (!_context5.sent) {
296
+ _context5.next = 23;
297
+ break;
298
+ }
299
+ _this$_settings$getSe2 = this._settings.getSettings(), size = _this$_settings$getSe2.size, margin = _this$_settings$getSe2.margin, rounded = _this$_settings$getSe2.rounded, format = _this$_settings$getSe2.format;
300
+ _this$_settings$getDe4 = this._settings.getDestination(), local = _this$_settings$getDe4.local, drive = _this$_settings$getDe4.drive;
301
+ qr = new _image["default"](folder, size, margin, logo, data, this._settings.getColors(), this._settings.getFont(), rounded, typeof captionCallback === "function" ? captionCallback(folder) : folder.name);
302
+ console.info("Creating QR code for \"".concat(folder.name, "\"."));
303
+ if (!local) {
304
+ _context5.next = 17;
305
+ break;
306
+ }
307
+ _context5.t0 = result;
308
+ _context5.next = 15;
309
+ return qr.save(local, format);
310
+ case 15:
311
+ _context5.t1 = _context5.sent;
312
+ _context5.t0.push.call(_context5.t0, _context5.t1);
313
+ case 17:
314
+ if (!drive) {
315
+ _context5.next = 23;
316
+ break;
317
+ }
318
+ _context5.t2 = result;
319
+ _context5.next = 21;
320
+ return qr.upload(drive, format, this._client);
321
+ case 21:
322
+ _context5.t3 = _context5.sent;
323
+ _context5.t2.push.call(_context5.t2, _context5.t3);
324
+ case 23:
325
+ _context5.next = 25;
326
+ return this.process(folders, logo, data, captionCallback, result, index + 1);
327
+ case 25:
328
+ _context5.next = 30;
329
+ break;
330
+ case 27:
331
+ _context5.prev = 27;
332
+ _context5.t4 = _context5["catch"](3);
333
+ console.error("Error creating QR code for \"".concat(folder.name, "\"."), _context5.t4);
334
+ case 30:
335
+ case "end":
336
+ return _context5.stop();
337
+ }
338
+ }, _callee5, this, [[3, 27]]);
339
+ }));
340
+ function process(_x5, _x6, _x7, _x8, _x9) {
341
+ return _process.apply(this, arguments);
342
+ }
343
+ return process;
344
+ }())
345
+ }]);
346
+ }();
@@ -5,9 +5,17 @@ Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
7
  exports["default"] = void 0;
8
- var _generate = _interopRequireDefault(require("./generate"));
8
+ var _generator = _interopRequireDefault(require("./generator"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
10
+ function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
11
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
12
+ function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
13
+ function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
14
+ function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
15
+ function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
16
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
17
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
18
+ function _OverloadYield(e, d) { this.v = e, this.k = d; }
11
19
  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); }
12
20
  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.
13
21
  //
@@ -23,21 +31,29 @@ function _asyncToGenerator(n) { return function () { var t = this, e = arguments
23
31
  // See the License for the specific language governing permissions and
24
32
  // limitations under the License.
25
33
  var _default = exports["default"] = /*#__PURE__*/function () {
26
- var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(drive, output, logo, colors, font, size, margin) {
27
- var rounded,
28
- format,
29
- credentials,
34
+ var _ref = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee(source, output, logo, settings, colors, font) {
35
+ var credentials,
30
36
  captionCallback,
37
+ file,
38
+ generator,
31
39
  _args = arguments;
32
40
  return _regeneratorRuntime().wrap(function _callee$(_context) {
33
41
  while (1) switch (_context.prev = _context.next) {
34
42
  case 0:
35
- rounded = _args.length > 7 && _args[7] !== undefined ? _args[7] : false;
36
- format = _args.length > 8 && _args[8] !== undefined ? _args[8] : "PDF";
37
- credentials = _args.length > 9 && _args[9] !== undefined ? _args[9] : null;
38
- captionCallback = _args.length > 10 && _args[10] !== undefined ? _args[10] : null;
43
+ credentials = _args.length > 6 && _args[6] !== undefined ? _args[6] : null;
44
+ captionCallback = _args.length > 7 && _args[7] !== undefined ? _args[7] : null;
45
+ file = _args.length > 8 && _args[8] !== undefined ? _args[8] : null;
46
+ generator = new _generator["default"](credentials, file, {
47
+ source: source,
48
+ destination: {
49
+ local: output
50
+ },
51
+ settings: settings,
52
+ colors: colors,
53
+ font: font
54
+ });
39
55
  _context.next = 6;
40
- return (0, _generate["default"])(drive, output, logo, colors, font, size, margin, rounded, credentials, format, true, captionCallback);
56
+ return generator.generate(logo, captionCallback);
41
57
  case 6:
42
58
  return _context.abrupt("return", _context.sent);
43
59
  case 7:
@@ -46,7 +62,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
46
62
  }
47
63
  }, _callee);
48
64
  }));
49
- return function (_x, _x2, _x3, _x4, _x5, _x6, _x7) {
65
+ return function (_x, _x2, _x3, _x4, _x5, _x6) {
50
66
  return _ref.apply(this, arguments);
51
67
  };
52
68
  }();
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.local = exports.drive = exports["default"] = void 0;
6
+ exports["default"] = void 0;
7
7
  var _local = _interopRequireDefault(require("./generator/local"));
8
8
  var _drive = _interopRequireDefault(require("./generator/drive"));
9
9
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
@@ -20,10 +20,7 @@ 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
-
24
- var local = exports.local = _local["default"];
25
- var drive = exports.drive = _drive["default"];
26
23
  var _default = exports["default"] = {
27
- local: local,
28
- drive: drive
24
+ local: _local["default"],
25
+ drive: _drive["default"]
29
26
  };
@@ -13,7 +13,15 @@ var _fillMargin = _interopRequireDefault(require("./extension/fill-margin"));
13
13
  var _document = _interopRequireDefault(require("./extension/document"));
14
14
  var _undef = _interopRequireDefault(require("./extension/undef"));
15
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
16
- function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return r; }; var t, r = {}, e = Object.prototype, n = e.hasOwnProperty, o = "function" == typeof Symbol ? Symbol : {}, i = o.iterator || "@@iterator", a = o.asyncIterator || "@@asyncIterator", u = o.toStringTag || "@@toStringTag"; function c(t, r, e, n) { return Object.defineProperty(t, r, { value: e, enumerable: !n, configurable: !n, writable: !n }); } try { c({}, ""); } catch (t) { c = function c(t, r, e) { return t[r] = e; }; } function h(r, e, n, o) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype); return c(a, "_invoke", function (r, e, n) { var o = 1; return function (i, a) { if (3 === o) throw Error("Generator is already running"); if (4 === o) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var u = n.delegate; if (u) { var c = d(u, n); if (c) { if (c === f) continue; return c; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (1 === o) throw o = 4, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = 3; var h = s(r, e, n); if ("normal" === h.type) { if (o = n.done ? 4 : 2, h.arg === f) continue; return { value: h.arg, done: n.done }; } "throw" === h.type && (o = 4, n.method = "throw", n.arg = h.arg); } }; }(r, n, new Context(o || [])), !0), a; } function s(t, r, e) { try { return { type: "normal", arg: t.call(r, e) }; } catch (t) { return { type: "throw", arg: t }; } } r.wrap = h; var f = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var l = {}; c(l, i, function () { return this; }); var p = Object.getPrototypeOf, y = p && p(p(x([]))); y && y !== e && n.call(y, i) && (l = y); var v = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(l); function g(t) { ["next", "throw", "return"].forEach(function (r) { c(t, r, function (t) { return this._invoke(r, t); }); }); } function AsyncIterator(t, r) { function e(o, i, a, u) { var c = s(t[o], t, i); if ("throw" !== c.type) { var h = c.arg, f = h.value; return f && "object" == _typeof(f) && n.call(f, "__await") ? r.resolve(f.__await).then(function (t) { e("next", t, a, u); }, function (t) { e("throw", t, a, u); }) : r.resolve(f).then(function (t) { h.value = t, a(h); }, function (t) { return e("throw", t, a, u); }); } u(c.arg); } var o; c(this, "_invoke", function (t, n) { function i() { return new r(function (r, o) { e(t, n, r, o); }); } return o = o ? o.then(i, i) : i(); }, !0); } function d(r, e) { var n = e.method, o = r.i[n]; if (o === t) return e.delegate = null, "throw" === n && r.i["return"] && (e.method = "return", e.arg = t, d(r, e), "throw" === e.method) || "return" !== n && (e.method = "throw", e.arg = new TypeError("The iterator does not provide a '" + n + "' method")), f; var i = s(o, r.i, e.arg); if ("throw" === i.type) return e.method = "throw", e.arg = i.arg, e.delegate = null, f; var a = i.arg; return a ? a.done ? (e[r.r] = a.value, e.next = r.n, "return" !== e.method && (e.method = "next", e.arg = t), e.delegate = null, f) : a : (e.method = "throw", e.arg = new TypeError("iterator result is not an object"), e.delegate = null, f); } function w(t) { this.tryEntries.push(t); } function m(r) { var e = r[4] || {}; e.type = "normal", e.arg = t, r[4] = e; } function Context(t) { this.tryEntries = [[-1]], t.forEach(w, this), this.reset(!0); } function x(r) { if (null != r) { var e = r[i]; if (e) return e.call(r); if ("function" == typeof r.next) return r; if (!isNaN(r.length)) { var o = -1, a = function e() { for (; ++o < r.length;) if (n.call(r, o)) return e.value = r[o], e.done = !1, e; return e.value = t, e.done = !0, e; }; return a.next = a; } } throw new TypeError(_typeof(r) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, c(v, "constructor", GeneratorFunctionPrototype), c(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = c(GeneratorFunctionPrototype, u, "GeneratorFunction"), r.isGeneratorFunction = function (t) { var r = "function" == typeof t && t.constructor; return !!r && (r === GeneratorFunction || "GeneratorFunction" === (r.displayName || r.name)); }, r.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, c(t, u, "GeneratorFunction")), t.prototype = Object.create(v), t; }, r.awrap = function (t) { return { __await: t }; }, g(AsyncIterator.prototype), c(AsyncIterator.prototype, a, function () { return this; }), r.AsyncIterator = AsyncIterator, r.async = function (t, e, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(h(t, e, n, o), i); return r.isGeneratorFunction(e) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, g(v), c(v, u, "Generator"), c(v, i, function () { return this; }), c(v, "toString", function () { return "[object Generator]"; }), r.keys = function (t) { var r = Object(t), e = []; for (var n in r) e.unshift(n); return function t() { for (; e.length;) if ((n = e.pop()) in r) return t.value = n, t.done = !1, t; return t.done = !0, t; }; }, r.values = x, Context.prototype = { constructor: Context, reset: function reset(r) { if (this.prev = this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(m), !r) for (var e in this) "t" === e.charAt(0) && n.call(this, e) && !isNaN(+e.slice(1)) && (this[e] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0][4]; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(r) { if (this.done) throw r; var e = this; function n(t) { a.type = "throw", a.arg = r, e.next = t; } for (var o = e.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i[4], u = this.prev, c = i[1], h = i[2]; if (-1 === i[0]) return n("end"), !1; if (!c && !h) throw Error("try statement without catch or finally"); if (null != i[0] && i[0] <= u) { if (u < c) return this.method = "next", this.arg = t, n(c), !0; if (u < h) return n(h), !1; } } }, abrupt: function abrupt(t, r) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var n = this.tryEntries[e]; if (n[0] > -1 && n[0] <= this.prev && this.prev < n[2]) { var o = n; break; } } o && ("break" === t || "continue" === t) && o[0] <= r && r <= o[2] && (o = null); var i = o ? o[4] : {}; return i.type = t, i.arg = r, o ? (this.method = "next", this.next = o[2], f) : this.complete(i); }, complete: function complete(t, r) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && r && (this.next = r), f; }, finish: function finish(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[2] === t) return this.complete(e[4], e[3]), m(e), f; } }, "catch": function _catch(t) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var e = this.tryEntries[r]; if (e[0] === t) { var n = e[4]; if ("throw" === n.type) { var o = n.arg; m(e); } return o; } } throw Error("illegal catch attempt"); }, delegateYield: function delegateYield(r, e, n) { return this.delegate = { i: x(r), r: e, n: n }, "next" === this.method && (this.arg = t), f; } }, r; }
16
+ function _regeneratorRuntime() { "use strict"; var r = _regenerator(), e = r.m(_regeneratorRuntime), t = (Object.getPrototypeOf ? Object.getPrototypeOf(e) : e.__proto__).constructor; function n(r) { var e = "function" == typeof r && r.constructor; return !!e && (e === t || "GeneratorFunction" === (e.displayName || e.name)); } var o = { "throw": 1, "return": 2, "break": 3, "continue": 3 }; function a(r) { var e, t; return function (n) { e || (e = { stop: function stop() { return t(n.a, 2); }, "catch": function _catch() { return n.v; }, abrupt: function abrupt(r, e) { return t(n.a, o[r], e); }, delegateYield: function delegateYield(r, o, a) { return e.resultName = o, t(n.d, _regeneratorValues(r), a); }, finish: function finish(r) { return t(n.f, r); } }, t = function t(r, _t, o) { n.p = e.prev, n.n = e.next; try { return r(_t, o); } finally { e.next = n.n; } }), e.resultName && (e[e.resultName] = n.v, e.resultName = void 0), e.sent = n.v, e.next = n.n; try { return r.call(this, e); } finally { n.p = e.prev, n.n = e.next; } }; } return (_regeneratorRuntime = function _regeneratorRuntime() { return { wrap: function wrap(e, t, n, o) { return r.w(a(e), t, n, o && o.reverse()); }, isGeneratorFunction: n, mark: r.m, awrap: function awrap(r, e) { return new _OverloadYield(r, e); }, AsyncIterator: _regeneratorAsyncIterator, async: function async(r, e, t, o, u) { return (n(e) ? _regeneratorAsyncGen : _regeneratorAsync)(a(r), e, t, o, u); }, keys: _regeneratorKeys, values: _regeneratorValues }; })(); }
17
+ function _regeneratorValues(e) { if (null != e) { var t = e["function" == typeof Symbol && Symbol.iterator || "@@iterator"], r = 0; if (t) return t.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) return { next: function next() { return e && r >= e.length && (e = void 0), { value: e && e[r++], done: !e }; } }; } throw new TypeError(_typeof(e) + " is not iterable"); }
18
+ function _regeneratorKeys(e) { var n = Object(e), r = []; for (var t in n) r.unshift(t); return function e() { for (; r.length;) if ((t = r.pop()) in n) return e.value = t, e.done = !1, e; return e.done = !0, e; }; }
19
+ function _regeneratorAsync(n, e, r, t, o) { var a = _regeneratorAsyncGen(n, e, r, t, o); return a.next().then(function (n) { return n.done ? n.value : a.next(); }); }
20
+ function _regeneratorAsyncGen(r, e, t, o, n) { return new _regeneratorAsyncIterator(_regenerator().w(r, e, t, o), n || Promise); }
21
+ function _regeneratorAsyncIterator(t, e) { function n(r, o, i, f) { try { var c = t[r](o), u = c.value; return u instanceof _OverloadYield ? e.resolve(u.v).then(function (t) { n("next", t, i, f); }, function (t) { n("throw", t, i, f); }) : e.resolve(u).then(function (t) { c.value = t, i(c); }, function (t) { return n("throw", t, i, f); }); } catch (t) { f(t); } } var r; this.next || (_regeneratorDefine2(_regeneratorAsyncIterator.prototype), _regeneratorDefine2(_regeneratorAsyncIterator.prototype, "function" == typeof Symbol && Symbol.asyncIterator || "@asyncIterator", function () { return this; })), _regeneratorDefine2(this, "_invoke", function (t, o, i) { function f() { return new e(function (e, r) { n(t, i, e, r); }); } return r = r ? r.then(f, f) : f(); }, !0); }
22
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (c = i[4] || 3, u = i[5] === e ? i[3] : i[5], i[4] = 3, i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
23
+ function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { if (r) i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n;else { var o = function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); }; o("next", 0), o("throw", 1), o("return", 2); } }, _regeneratorDefine2(e, r, n, t); }
24
+ function _OverloadYield(e, d) { this.v = e, this.k = d; }
17
25
  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
26
  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.
19
27
  //
@@ -35,7 +43,7 @@ var _default = exports["default"] = /*#__PURE__*/function () {
35
43
  while (1) switch (_context.prev = _context.next) {
36
44
  case 0:
37
45
  _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;
38
- if (font.path && font.family) {
46
+ if (font && font !== null && font !== void 0 && font.path && font !== null && font !== void 0 && font.family) {
39
47
  registerFont(font.path, {
40
48
  family: font.family
41
49
  });
@@ -44,9 +52,9 @@ var _default = exports["default"] = /*#__PURE__*/function () {
44
52
  bg.parentElement.removeChild(bg);
45
53
  canvas = createCanvas(width, height + margin, "svg");
46
54
  context = canvas.getContext("2d");
47
- (0, _fillMargin["default"])(context, width, height, margin, borderOptions.color, rounded);
48
- context.font = font.family ? "bold ".concat(margin + 4, "px \"").concat(font.family, "\"") : "bold ".concat(margin + 4, "px");
49
- context.fillStyle = font.color || backgroundOptions.color;
55
+ (0, _fillMargin["default"])(context, width, height, margin, borderOptions === null || borderOptions === void 0 ? void 0 : borderOptions.color, rounded);
56
+ context.font = font !== null && font !== void 0 && font.family ? "bold ".concat(margin + 4, "px \"").concat(font.family, "\"") : "bold ".concat(margin + 4, "px");
57
+ context.fillStyle = (font === null || font === void 0 ? void 0 : font.color) || backgroundOptions.color;
50
58
  (0, _fillCaption["default"])(caption, context, canvas, margin);
51
59
  frame = (0, _document["default"])(canvas.toBuffer().toString());
52
60
  elements = frame.getElementsByTagName("svg")[0].getElementsByTagName("path");
@@ -4,9 +4,6 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _svgToPdfkit = _interopRequireDefault(require("svg-to-pdfkit"));
8
- var _pdfkit = _interopRequireDefault(require("pdfkit"));
9
- function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
10
7
  // Copyright 2024-2025 Pittica S.r.l.
11
8
  //
12
9
  // Licensed under the Apache License, Version 2.0 (the "License");
@@ -20,15 +17,15 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default":
20
17
  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
18
  // See the License for the specific language governing permissions and
22
19
  // limitations under the License.
23
- var _default = exports["default"] = function _default(size, margin, buffer) {
24
- var pdf = new _pdfkit["default"]({
25
- compress: false,
26
- size: [size * 0.75, (size + margin * 2) * 0.75]
27
- });
28
- (0, _svgToPdfkit["default"])(pdf, buffer.toString(), 0, 0, {
29
- width: size * 0.75,
30
- height: (size + margin) * 0.75,
31
- useCSS: false
32
- });
33
- return pdf;
20
+ /**
21
+ * Gets an output filename.
22
+ *
23
+ * @param {object} folder Google Drive folder object.
24
+ * @param {string} extension File extension.
25
+ * @returns {string} Output filename.
26
+ */
27
+ var _default = exports["default"] = function _default(_ref, extension) {
28
+ var name = _ref.name,
29
+ id = _ref.id;
30
+ return "".concat(name, " - ").concat(id, ".").concat(extension.toLowerCase());
34
31
  };