@azuro-org/images-generator 2.0.7 → 2.0.8
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/.nvmrc +1 -1
- package/dist/index.es.js +38 -38
- package/dist/templates/bet-og/index.js +1 -1
- package/lib/index.js +38 -38
- package/lib/templates/bet-og/index.js +1 -1
- package/package.json +6 -7
package/.nvmrc
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
22.20
|
package/dist/index.es.js
CHANGED
|
@@ -138,35 +138,35 @@ var Generator = /** @class */ (function () {
|
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
140
|
Generator.prototype.generate = function (props) {
|
|
141
|
-
var _a, _b;
|
|
141
|
+
var _a, _b, _c;
|
|
142
142
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
143
|
var maxAttempts, lastError, _loop_1, this_1, attempt, state_1, errorMessage;
|
|
144
|
-
return __generator(this, function (
|
|
145
|
-
switch (
|
|
144
|
+
return __generator(this, function (_d) {
|
|
145
|
+
switch (_d.label) {
|
|
146
146
|
case 0:
|
|
147
147
|
maxAttempts = 2;
|
|
148
148
|
_loop_1 = function (attempt) {
|
|
149
|
-
var template, templateProps, output, filename,
|
|
150
|
-
return __generator(this, function (
|
|
151
|
-
switch (
|
|
149
|
+
var template, templateProps, output, filename, _e, options, width, height, type, getHtml, _f, quality, _g, fullPage, _h, waitForFonts, _j, waitTimeout_1, _k, waitUntil, _l, skipAnimations, page, htmlContent, content, _m, screenshotOptions, imageBuffer, innerError_1, error_2;
|
|
150
|
+
return __generator(this, function (_o) {
|
|
151
|
+
switch (_o.label) {
|
|
152
152
|
case 0:
|
|
153
|
-
|
|
153
|
+
_o.trys.push([0, 23, , 26]);
|
|
154
154
|
if (!!this_1.browser) return [3 /*break*/, 2];
|
|
155
155
|
return [4 /*yield*/, this_1.run()];
|
|
156
156
|
case 1:
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
_o.sent();
|
|
158
|
+
_o.label = 2;
|
|
159
159
|
case 2:
|
|
160
|
-
template = props.template, templateProps = props.props, output = props.output, filename = props.filename,
|
|
160
|
+
template = props.template, templateProps = props.props, output = props.output, filename = props.filename, _e = props.options, options = _e === void 0 ? {} : _e;
|
|
161
161
|
// Validate template
|
|
162
162
|
if (!template.width || !template.height || !template.html) {
|
|
163
163
|
throw new Error('Invalid template: missing required properties');
|
|
164
164
|
}
|
|
165
165
|
width = template.width, height = template.height, type = template.type, getHtml = template.html;
|
|
166
|
-
|
|
166
|
+
_f = options.quality, quality = _f === void 0 ? type === 'jpeg' ? 85 : undefined : _f, _g = options.fullPage, fullPage = _g === void 0 ? false : _g, _h = options.waitForFonts, waitForFonts = _h === void 0 ? true : _h, _j = options.waitTimeout, waitTimeout_1 = _j === void 0 ? 2000 : _j, _k = options.waitUntil, waitUntil = _k === void 0 ? 'load' : _k, _l = options.skipAnimations, skipAnimations = _l === void 0 ? true : _l;
|
|
167
167
|
return [4 /*yield*/, this_1.browser.newPage()];
|
|
168
168
|
case 3:
|
|
169
|
-
page =
|
|
169
|
+
page = _o.sent();
|
|
170
170
|
// Set reasonable timeout instead of infinite
|
|
171
171
|
page.setDefaultNavigationTimeout((_a = this_1.options.timeout) !== null && _a !== void 0 ? _a : 30000);
|
|
172
172
|
page.setDefaultTimeout((_b = this_1.options.timeout) !== null && _b !== void 0 ? _b : 30000);
|
|
@@ -174,15 +174,15 @@ var Generator = /** @class */ (function () {
|
|
|
174
174
|
return [4 /*yield*/, page.setCacheEnabled(false)];
|
|
175
175
|
case 4:
|
|
176
176
|
// Optimize page performance
|
|
177
|
-
|
|
177
|
+
_o.sent();
|
|
178
178
|
return [4 /*yield*/, page.setJavaScriptEnabled(true)];
|
|
179
179
|
case 5:
|
|
180
|
-
|
|
180
|
+
_o.sent();
|
|
181
181
|
// Block unnecessary network requests for faster rendering
|
|
182
182
|
return [4 /*yield*/, page.setRequestInterception(true)];
|
|
183
183
|
case 6:
|
|
184
184
|
// Block unnecessary network requests for faster rendering
|
|
185
|
-
|
|
185
|
+
_o.sent();
|
|
186
186
|
page.on('request', function (req) {
|
|
187
187
|
var resourceType = req.resourceType();
|
|
188
188
|
if (['media', 'websocket', 'manifest', 'texttrack'].includes(resourceType)) {
|
|
@@ -192,21 +192,21 @@ var Generator = /** @class */ (function () {
|
|
|
192
192
|
req.continue();
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
|
|
195
|
+
_o.label = 7;
|
|
196
196
|
case 7:
|
|
197
|
-
|
|
197
|
+
_o.trys.push([7, 20, , 22]);
|
|
198
198
|
// Set viewport for this generation
|
|
199
199
|
return [4 /*yield*/, page.setViewport({
|
|
200
200
|
width: width,
|
|
201
201
|
height: height,
|
|
202
|
-
deviceScaleFactor: 1,
|
|
202
|
+
deviceScaleFactor: ((_c = props.template) === null || _c === void 0 ? void 0 : _c.scaleFactor) || 1,
|
|
203
203
|
})];
|
|
204
204
|
case 8:
|
|
205
205
|
// Set viewport for this generation
|
|
206
|
-
|
|
206
|
+
_o.sent();
|
|
207
207
|
return [4 /*yield*/, getHtml(templateProps)];
|
|
208
208
|
case 9:
|
|
209
|
-
htmlContent =
|
|
209
|
+
htmlContent = _o.sent();
|
|
210
210
|
if (!htmlContent || typeof htmlContent !== 'string') {
|
|
211
211
|
throw new Error('Template html function must return a non-empty string');
|
|
212
212
|
}
|
|
@@ -219,7 +219,7 @@ var Generator = /** @class */ (function () {
|
|
|
219
219
|
])];
|
|
220
220
|
case 10:
|
|
221
221
|
// Load content with faster wait strategy
|
|
222
|
-
|
|
222
|
+
_o.sent();
|
|
223
223
|
if (!waitForFonts) return [3 /*break*/, 12];
|
|
224
224
|
return [4 /*yield*/, Promise.race([
|
|
225
225
|
page.evaluate(function () { return document.fonts.ready; }),
|
|
@@ -228,24 +228,24 @@ var Generator = /** @class */ (function () {
|
|
|
228
228
|
}),
|
|
229
229
|
]).catch(function () { })];
|
|
230
230
|
case 11:
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
_o.sent();
|
|
232
|
+
_o.label = 12;
|
|
233
233
|
case 12:
|
|
234
234
|
if (!!skipAnimations) return [3 /*break*/, 14];
|
|
235
235
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
236
236
|
case 13:
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
_o.sent();
|
|
238
|
+
_o.label = 14;
|
|
239
239
|
case 14:
|
|
240
240
|
if (!fullPage) return [3 /*break*/, 15];
|
|
241
|
-
|
|
241
|
+
_m = page;
|
|
242
242
|
return [3 /*break*/, 17];
|
|
243
243
|
case 15: return [4 /*yield*/, page.$('body')];
|
|
244
244
|
case 16:
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
_m = _o.sent();
|
|
246
|
+
_o.label = 17;
|
|
247
247
|
case 17:
|
|
248
|
-
content =
|
|
248
|
+
content = _m;
|
|
249
249
|
if (!content) {
|
|
250
250
|
throw new Error('Failed to find content element');
|
|
251
251
|
}
|
|
@@ -258,25 +258,25 @@ var Generator = /** @class */ (function () {
|
|
|
258
258
|
}
|
|
259
259
|
return [4 /*yield*/, content.screenshot(screenshotOptions)];
|
|
260
260
|
case 18:
|
|
261
|
-
imageBuffer =
|
|
261
|
+
imageBuffer = _o.sent();
|
|
262
262
|
return [4 /*yield*/, page.close()];
|
|
263
263
|
case 19:
|
|
264
|
-
|
|
264
|
+
_o.sent();
|
|
265
265
|
return [2 /*return*/, { value: imageBuffer }];
|
|
266
266
|
case 20:
|
|
267
|
-
innerError_1 =
|
|
267
|
+
innerError_1 = _o.sent();
|
|
268
268
|
return [4 /*yield*/, page.close().catch(function () { })];
|
|
269
269
|
case 21:
|
|
270
|
-
|
|
270
|
+
_o.sent();
|
|
271
271
|
throw innerError_1;
|
|
272
272
|
case 22: return [3 /*break*/, 26];
|
|
273
273
|
case 23:
|
|
274
|
-
error_2 =
|
|
274
|
+
error_2 = _o.sent();
|
|
275
275
|
lastError = error_2;
|
|
276
276
|
if (!(attempt < maxAttempts && isProtocolTimeoutError(error_2))) return [3 /*break*/, 25];
|
|
277
277
|
return [4 /*yield*/, this_1.cleanup()];
|
|
278
278
|
case 24:
|
|
279
|
-
|
|
279
|
+
_o.sent();
|
|
280
280
|
return [2 /*return*/, "continue"];
|
|
281
281
|
case 25: return [2 /*return*/, "break"];
|
|
282
282
|
case 26: return [2 /*return*/];
|
|
@@ -285,17 +285,17 @@ var Generator = /** @class */ (function () {
|
|
|
285
285
|
};
|
|
286
286
|
this_1 = this;
|
|
287
287
|
attempt = 1;
|
|
288
|
-
|
|
288
|
+
_d.label = 1;
|
|
289
289
|
case 1:
|
|
290
290
|
if (!(attempt <= maxAttempts)) return [3 /*break*/, 4];
|
|
291
291
|
return [5 /*yield**/, _loop_1(attempt)];
|
|
292
292
|
case 2:
|
|
293
|
-
state_1 =
|
|
293
|
+
state_1 = _d.sent();
|
|
294
294
|
if (typeof state_1 === "object")
|
|
295
295
|
return [2 /*return*/, state_1.value];
|
|
296
296
|
if (state_1 === "break")
|
|
297
297
|
return [3 /*break*/, 4];
|
|
298
|
-
|
|
298
|
+
_d.label = 3;
|
|
299
299
|
case 3:
|
|
300
300
|
attempt++;
|
|
301
301
|
return [3 /*break*/, 1];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {_ as __awaiter,a as __generator,g as getFile,b as getBase64Image}from'../../index-dd1b4780.js';import path from'path';import'fs';import'util';import'stream';import'http';import'https';import'url';import'crypto';import'http2';import'assert';import'tty';import'zlib';import'events';var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};var dayjs_min = {exports: {}};(function (module, exports) {
|
|
2
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",
|
|
2
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
3
3
|
} (dayjs_min));
|
|
4
4
|
|
|
5
5
|
var dayjs = dayjs_min.exports;var template = {
|
package/lib/index.js
CHANGED
|
@@ -138,35 +138,35 @@ var Generator = /** @class */ (function () {
|
|
|
138
138
|
});
|
|
139
139
|
};
|
|
140
140
|
Generator.prototype.generate = function (props) {
|
|
141
|
-
var _a, _b;
|
|
141
|
+
var _a, _b, _c;
|
|
142
142
|
return __awaiter(this, void 0, void 0, function () {
|
|
143
143
|
var maxAttempts, lastError, _loop_1, this_1, attempt, state_1, errorMessage;
|
|
144
|
-
return __generator(this, function (
|
|
145
|
-
switch (
|
|
144
|
+
return __generator(this, function (_d) {
|
|
145
|
+
switch (_d.label) {
|
|
146
146
|
case 0:
|
|
147
147
|
maxAttempts = 2;
|
|
148
148
|
_loop_1 = function (attempt) {
|
|
149
|
-
var template, templateProps, output, filename,
|
|
150
|
-
return __generator(this, function (
|
|
151
|
-
switch (
|
|
149
|
+
var template, templateProps, output, filename, _e, options, width, height, type, getHtml, _f, quality, _g, fullPage, _h, waitForFonts, _j, waitTimeout_1, _k, waitUntil, _l, skipAnimations, page, htmlContent, content, _m, screenshotOptions, imageBuffer, innerError_1, error_2;
|
|
150
|
+
return __generator(this, function (_o) {
|
|
151
|
+
switch (_o.label) {
|
|
152
152
|
case 0:
|
|
153
|
-
|
|
153
|
+
_o.trys.push([0, 23, , 26]);
|
|
154
154
|
if (!!this_1.browser) return [3 /*break*/, 2];
|
|
155
155
|
return [4 /*yield*/, this_1.run()];
|
|
156
156
|
case 1:
|
|
157
|
-
|
|
158
|
-
|
|
157
|
+
_o.sent();
|
|
158
|
+
_o.label = 2;
|
|
159
159
|
case 2:
|
|
160
|
-
template = props.template, templateProps = props.props, output = props.output, filename = props.filename,
|
|
160
|
+
template = props.template, templateProps = props.props, output = props.output, filename = props.filename, _e = props.options, options = _e === void 0 ? {} : _e;
|
|
161
161
|
// Validate template
|
|
162
162
|
if (!template.width || !template.height || !template.html) {
|
|
163
163
|
throw new Error('Invalid template: missing required properties');
|
|
164
164
|
}
|
|
165
165
|
width = template.width, height = template.height, type = template.type, getHtml = template.html;
|
|
166
|
-
|
|
166
|
+
_f = options.quality, quality = _f === void 0 ? type === 'jpeg' ? 85 : undefined : _f, _g = options.fullPage, fullPage = _g === void 0 ? false : _g, _h = options.waitForFonts, waitForFonts = _h === void 0 ? true : _h, _j = options.waitTimeout, waitTimeout_1 = _j === void 0 ? 2000 : _j, _k = options.waitUntil, waitUntil = _k === void 0 ? 'load' : _k, _l = options.skipAnimations, skipAnimations = _l === void 0 ? true : _l;
|
|
167
167
|
return [4 /*yield*/, this_1.browser.newPage()];
|
|
168
168
|
case 3:
|
|
169
|
-
page =
|
|
169
|
+
page = _o.sent();
|
|
170
170
|
// Set reasonable timeout instead of infinite
|
|
171
171
|
page.setDefaultNavigationTimeout((_a = this_1.options.timeout) !== null && _a !== void 0 ? _a : 30000);
|
|
172
172
|
page.setDefaultTimeout((_b = this_1.options.timeout) !== null && _b !== void 0 ? _b : 30000);
|
|
@@ -174,15 +174,15 @@ var Generator = /** @class */ (function () {
|
|
|
174
174
|
return [4 /*yield*/, page.setCacheEnabled(false)];
|
|
175
175
|
case 4:
|
|
176
176
|
// Optimize page performance
|
|
177
|
-
|
|
177
|
+
_o.sent();
|
|
178
178
|
return [4 /*yield*/, page.setJavaScriptEnabled(true)];
|
|
179
179
|
case 5:
|
|
180
|
-
|
|
180
|
+
_o.sent();
|
|
181
181
|
// Block unnecessary network requests for faster rendering
|
|
182
182
|
return [4 /*yield*/, page.setRequestInterception(true)];
|
|
183
183
|
case 6:
|
|
184
184
|
// Block unnecessary network requests for faster rendering
|
|
185
|
-
|
|
185
|
+
_o.sent();
|
|
186
186
|
page.on('request', function (req) {
|
|
187
187
|
var resourceType = req.resourceType();
|
|
188
188
|
if (['media', 'websocket', 'manifest', 'texttrack'].includes(resourceType)) {
|
|
@@ -192,21 +192,21 @@ var Generator = /** @class */ (function () {
|
|
|
192
192
|
req.continue();
|
|
193
193
|
}
|
|
194
194
|
});
|
|
195
|
-
|
|
195
|
+
_o.label = 7;
|
|
196
196
|
case 7:
|
|
197
|
-
|
|
197
|
+
_o.trys.push([7, 20, , 22]);
|
|
198
198
|
// Set viewport for this generation
|
|
199
199
|
return [4 /*yield*/, page.setViewport({
|
|
200
200
|
width: width,
|
|
201
201
|
height: height,
|
|
202
|
-
deviceScaleFactor: 1,
|
|
202
|
+
deviceScaleFactor: ((_c = props.template) === null || _c === void 0 ? void 0 : _c.scaleFactor) || 1,
|
|
203
203
|
})];
|
|
204
204
|
case 8:
|
|
205
205
|
// Set viewport for this generation
|
|
206
|
-
|
|
206
|
+
_o.sent();
|
|
207
207
|
return [4 /*yield*/, getHtml(templateProps)];
|
|
208
208
|
case 9:
|
|
209
|
-
htmlContent =
|
|
209
|
+
htmlContent = _o.sent();
|
|
210
210
|
if (!htmlContent || typeof htmlContent !== 'string') {
|
|
211
211
|
throw new Error('Template html function must return a non-empty string');
|
|
212
212
|
}
|
|
@@ -219,7 +219,7 @@ var Generator = /** @class */ (function () {
|
|
|
219
219
|
])];
|
|
220
220
|
case 10:
|
|
221
221
|
// Load content with faster wait strategy
|
|
222
|
-
|
|
222
|
+
_o.sent();
|
|
223
223
|
if (!waitForFonts) return [3 /*break*/, 12];
|
|
224
224
|
return [4 /*yield*/, Promise.race([
|
|
225
225
|
page.evaluate(function () { return document.fonts.ready; }),
|
|
@@ -228,24 +228,24 @@ var Generator = /** @class */ (function () {
|
|
|
228
228
|
}),
|
|
229
229
|
]).catch(function () { })];
|
|
230
230
|
case 11:
|
|
231
|
-
|
|
232
|
-
|
|
231
|
+
_o.sent();
|
|
232
|
+
_o.label = 12;
|
|
233
233
|
case 12:
|
|
234
234
|
if (!!skipAnimations) return [3 /*break*/, 14];
|
|
235
235
|
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 100); })];
|
|
236
236
|
case 13:
|
|
237
|
-
|
|
238
|
-
|
|
237
|
+
_o.sent();
|
|
238
|
+
_o.label = 14;
|
|
239
239
|
case 14:
|
|
240
240
|
if (!fullPage) return [3 /*break*/, 15];
|
|
241
|
-
|
|
241
|
+
_m = page;
|
|
242
242
|
return [3 /*break*/, 17];
|
|
243
243
|
case 15: return [4 /*yield*/, page.$('body')];
|
|
244
244
|
case 16:
|
|
245
|
-
|
|
246
|
-
|
|
245
|
+
_m = _o.sent();
|
|
246
|
+
_o.label = 17;
|
|
247
247
|
case 17:
|
|
248
|
-
content =
|
|
248
|
+
content = _m;
|
|
249
249
|
if (!content) {
|
|
250
250
|
throw new Error('Failed to find content element');
|
|
251
251
|
}
|
|
@@ -258,25 +258,25 @@ var Generator = /** @class */ (function () {
|
|
|
258
258
|
}
|
|
259
259
|
return [4 /*yield*/, content.screenshot(screenshotOptions)];
|
|
260
260
|
case 18:
|
|
261
|
-
imageBuffer =
|
|
261
|
+
imageBuffer = _o.sent();
|
|
262
262
|
return [4 /*yield*/, page.close()];
|
|
263
263
|
case 19:
|
|
264
|
-
|
|
264
|
+
_o.sent();
|
|
265
265
|
return [2 /*return*/, { value: imageBuffer }];
|
|
266
266
|
case 20:
|
|
267
|
-
innerError_1 =
|
|
267
|
+
innerError_1 = _o.sent();
|
|
268
268
|
return [4 /*yield*/, page.close().catch(function () { })];
|
|
269
269
|
case 21:
|
|
270
|
-
|
|
270
|
+
_o.sent();
|
|
271
271
|
throw innerError_1;
|
|
272
272
|
case 22: return [3 /*break*/, 26];
|
|
273
273
|
case 23:
|
|
274
|
-
error_2 =
|
|
274
|
+
error_2 = _o.sent();
|
|
275
275
|
lastError = error_2;
|
|
276
276
|
if (!(attempt < maxAttempts && isProtocolTimeoutError(error_2))) return [3 /*break*/, 25];
|
|
277
277
|
return [4 /*yield*/, this_1.cleanup()];
|
|
278
278
|
case 24:
|
|
279
|
-
|
|
279
|
+
_o.sent();
|
|
280
280
|
return [2 /*return*/, "continue"];
|
|
281
281
|
case 25: return [2 /*return*/, "break"];
|
|
282
282
|
case 26: return [2 /*return*/];
|
|
@@ -285,17 +285,17 @@ var Generator = /** @class */ (function () {
|
|
|
285
285
|
};
|
|
286
286
|
this_1 = this;
|
|
287
287
|
attempt = 1;
|
|
288
|
-
|
|
288
|
+
_d.label = 1;
|
|
289
289
|
case 1:
|
|
290
290
|
if (!(attempt <= maxAttempts)) return [3 /*break*/, 4];
|
|
291
291
|
return [5 /*yield**/, _loop_1(attempt)];
|
|
292
292
|
case 2:
|
|
293
|
-
state_1 =
|
|
293
|
+
state_1 = _d.sent();
|
|
294
294
|
if (typeof state_1 === "object")
|
|
295
295
|
return [2 /*return*/, state_1.value];
|
|
296
296
|
if (state_1 === "break")
|
|
297
297
|
return [3 /*break*/, 4];
|
|
298
|
-
|
|
298
|
+
_d.label = 3;
|
|
299
299
|
case 3:
|
|
300
300
|
attempt++;
|
|
301
301
|
return [3 /*break*/, 1];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
'use strict';var index=require('../../index-0f16798b.js'),path=require('path');require('fs'),require('util'),require('stream'),require('http'),require('https'),require('url'),require('crypto'),require('http2'),require('assert'),require('tty'),require('zlib'),require('events');function _interopDefaultLegacy(e){return e&&typeof e==='object'&&'default'in e?e:{'default':e}}var path__default=/*#__PURE__*/_interopDefaultLegacy(path);var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'undefined' ? self : {};var dayjs_min = {exports: {}};(function (module, exports) {
|
|
2
|
-
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",
|
|
2
|
+
!function(t,e){module.exports=e();}(commonjsGlobal,(function(){var t=1e3,e=6e4,n=36e5,r="millisecond",i="second",s="minute",u="hour",a="day",o="week",c="month",f="quarter",h="year",d="date",l="Invalid Date",$=/^(\d{4})[-/]?(\d{1,2})?[-/]?(\d{0,2})[Tt\s]*(\d{1,2})?:?(\d{1,2})?:?(\d{1,2})?[.:]?(\d+)?$/,y=/\[([^\]]+)]|Y{1,4}|M{1,4}|D{1,2}|d{1,4}|H{1,2}|h{1,2}|a|A|m{1,2}|s{1,2}|Z{1,2}|SSS/g,M={name:"en",weekdays:"Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"),months:"January_February_March_April_May_June_July_August_September_October_November_December".split("_"),ordinal:function(t){var e=["th","st","nd","rd"],n=t%100;return "["+t+(e[(n-20)%10]||e[n]||e[0])+"]"}},m=function(t,e,n){var r=String(t);return !r||r.length>=e?t:""+Array(e+1-r.length).join(n)+t},v={s:m,z:function(t){var e=-t.utcOffset(),n=Math.abs(e),r=Math.floor(n/60),i=n%60;return (e<=0?"+":"-")+m(r,2,"0")+":"+m(i,2,"0")},m:function t(e,n){if(e.date()<n.date())return -t(n,e);var r=12*(n.year()-e.year())+(n.month()-e.month()),i=e.clone().add(r,c),s=n-i<0,u=e.clone().add(r+(s?-1:1),c);return +(-(r+(n-i)/(s?i-u:u-i))||0)},a:function(t){return t<0?Math.ceil(t)||0:Math.floor(t)},p:function(t){return {M:c,y:h,w:o,d:a,D:d,h:u,m:s,s:i,ms:r,Q:f}[t]||String(t||"").toLowerCase().replace(/s$/,"")},u:function(t){return void 0===t}},g="en",D={};D[g]=M;var p="$isDayjsObject",S=function(t){return t instanceof _||!(!t||!t[p])},w=function t(e,n,r){var i;if(!e)return g;if("string"==typeof e){var s=e.toLowerCase();D[s]&&(i=s),n&&(D[s]=n,i=s);var u=e.split("-");if(!i&&u.length>1)return t(u[0])}else {var a=e.name;D[a]=e,i=a;}return !r&&i&&(g=i),i||!r&&g},O=function(t,e){if(S(t))return t.clone();var n="object"==typeof e?e:{};return n.date=t,n.args=arguments,new _(n)},b=v;b.l=w,b.i=S,b.w=function(t,e){return O(t,{locale:e.$L,utc:e.$u,x:e.$x,$offset:e.$offset})};var _=function(){function M(t){this.$L=w(t.locale,null,!0),this.parse(t),this.$x=this.$x||t.x||{},this[p]=!0;}var m=M.prototype;return m.parse=function(t){this.$d=function(t){var e=t.date,n=t.utc;if(null===e)return new Date(NaN);if(b.u(e))return new Date;if(e instanceof Date)return new Date(e);if("string"==typeof e&&!/Z$/i.test(e)){var r=e.match($);if(r){var i=r[2]-1||0,s=(r[7]||"0").substring(0,3);return n?new Date(Date.UTC(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)):new Date(r[1],i,r[3]||1,r[4]||0,r[5]||0,r[6]||0,s)}}return new Date(e)}(t),this.init();},m.init=function(){var t=this.$d;this.$y=t.getFullYear(),this.$M=t.getMonth(),this.$D=t.getDate(),this.$W=t.getDay(),this.$H=t.getHours(),this.$m=t.getMinutes(),this.$s=t.getSeconds(),this.$ms=t.getMilliseconds();},m.$utils=function(){return b},m.isValid=function(){return !(this.$d.toString()===l)},m.isSame=function(t,e){var n=O(t);return this.startOf(e)<=n&&n<=this.endOf(e)},m.isAfter=function(t,e){return O(t)<this.startOf(e)},m.isBefore=function(t,e){return this.endOf(e)<O(t)},m.$g=function(t,e,n){return b.u(t)?this[e]:this.set(n,t)},m.unix=function(){return Math.floor(this.valueOf()/1e3)},m.valueOf=function(){return this.$d.getTime()},m.startOf=function(t,e){var n=this,r=!!b.u(e)||e,f=b.p(t),l=function(t,e){var i=b.w(n.$u?Date.UTC(n.$y,e,t):new Date(n.$y,e,t),n);return r?i:i.endOf(a)},$=function(t,e){return b.w(n.toDate()[t].apply(n.toDate("s"),(r?[0,0,0,0]:[23,59,59,999]).slice(e)),n)},y=this.$W,M=this.$M,m=this.$D,v="set"+(this.$u?"UTC":"");switch(f){case h:return r?l(1,0):l(31,11);case c:return r?l(1,M):l(0,M+1);case o:var g=this.$locale().weekStart||0,D=(y<g?y+7:y)-g;return l(r?m-D:m+(6-D),M);case a:case d:return $(v+"Hours",0);case u:return $(v+"Minutes",1);case s:return $(v+"Seconds",2);case i:return $(v+"Milliseconds",3);default:return this.clone()}},m.endOf=function(t){return this.startOf(t,!1)},m.$set=function(t,e){var n,o=b.p(t),f="set"+(this.$u?"UTC":""),l=(n={},n[a]=f+"Date",n[d]=f+"Date",n[c]=f+"Month",n[h]=f+"FullYear",n[u]=f+"Hours",n[s]=f+"Minutes",n[i]=f+"Seconds",n[r]=f+"Milliseconds",n)[o],$=o===a?this.$D+(e-this.$W):e;if(o===c||o===h){var y=this.clone().set(d,1);y.$d[l]($),y.init(),this.$d=y.set(d,Math.min(this.$D,y.daysInMonth())).$d;}else l&&this.$d[l]($);return this.init(),this},m.set=function(t,e){return this.clone().$set(t,e)},m.get=function(t){return this[b.p(t)]()},m.add=function(r,f){var d,l=this;r=Number(r);var $=b.p(f),y=function(t){var e=O(l);return b.w(e.date(e.date()+Math.round(t*r)),l)};if($===c)return this.set(c,this.$M+r);if($===h)return this.set(h,this.$y+r);if($===a)return y(1);if($===o)return y(7);var M=(d={},d[s]=e,d[u]=n,d[i]=t,d)[$]||1,m=this.$d.getTime()+r*M;return b.w(m,this)},m.subtract=function(t,e){return this.add(-1*t,e)},m.format=function(t){var e=this,n=this.$locale();if(!this.isValid())return n.invalidDate||l;var r=t||"YYYY-MM-DDTHH:mm:ssZ",i=b.z(this),s=this.$H,u=this.$m,a=this.$M,o=n.weekdays,c=n.months,f=n.meridiem,h=function(t,n,i,s){return t&&(t[n]||t(e,r))||i[n].slice(0,s)},d=function(t){return b.s(s%12||12,t,"0")},$=f||function(t,e,n){var r=t<12?"AM":"PM";return n?r.toLowerCase():r};return r.replace(y,(function(t,r){return r||function(t){switch(t){case"YY":return String(e.$y).slice(-2);case"YYYY":return b.s(e.$y,4,"0");case"M":return a+1;case"MM":return b.s(a+1,2,"0");case"MMM":return h(n.monthsShort,a,c,3);case"MMMM":return h(c,a);case"D":return e.$D;case"DD":return b.s(e.$D,2,"0");case"d":return String(e.$W);case"dd":return h(n.weekdaysMin,e.$W,o,2);case"ddd":return h(n.weekdaysShort,e.$W,o,3);case"dddd":return o[e.$W];case"H":return String(s);case"HH":return b.s(s,2,"0");case"h":return d(1);case"hh":return d(2);case"a":return $(s,u,!0);case"A":return $(s,u,!1);case"m":return String(u);case"mm":return b.s(u,2,"0");case"s":return String(e.$s);case"ss":return b.s(e.$s,2,"0");case"SSS":return b.s(e.$ms,3,"0");case"Z":return i}return null}(t)||i.replace(":","")}))},m.utcOffset=function(){return 15*-Math.round(this.$d.getTimezoneOffset()/15)},m.diff=function(r,d,l){var $,y=this,M=b.p(d),m=O(r),v=(m.utcOffset()-this.utcOffset())*e,g=this-m,D=function(){return b.m(y,m)};switch(M){case h:$=D()/12;break;case c:$=D();break;case f:$=D()/3;break;case o:$=(g-v)/6048e5;break;case a:$=(g-v)/864e5;break;case u:$=g/n;break;case s:$=g/e;break;case i:$=g/t;break;default:$=g;}return l?$:b.a($)},m.daysInMonth=function(){return this.endOf(c).$D},m.$locale=function(){return D[this.$L]},m.locale=function(t,e){if(!t)return this.$L;var n=this.clone(),r=w(t,e,!0);return r&&(n.$L=r),n},m.clone=function(){return b.w(this.$d,this)},m.toDate=function(){return new Date(this.valueOf())},m.toJSON=function(){return this.isValid()?this.toISOString():null},m.toISOString=function(){return this.$d.toISOString()},m.toString=function(){return this.$d.toUTCString()},M}(),k=_.prototype;return O.prototype=k,[["$ms",r],["$s",i],["$m",s],["$H",u],["$W",a],["$M",c],["$y",h],["$D",d]].forEach((function(t){k[t[1]]=function(e){return this.$g(e,t[0],t[1])};})),O.extend=function(t,e){return t.$i||(t(e,_,O),t.$i=!0),O},O.locale=w,O.isDayjs=S,O.unix=function(t){return O(1e3*t)},O.en=D[g],O.Ls=D,O.p={},O}));
|
|
3
3
|
} (dayjs_min));
|
|
4
4
|
|
|
5
5
|
var dayjs = dayjs_min.exports;var template = {
|
package/package.json
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@azuro-org/images-generator",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.8",
|
|
4
4
|
"license": "ISC",
|
|
5
5
|
"engines": {
|
|
6
|
-
"node": ">=
|
|
7
|
-
"npm": ">=8.11.0"
|
|
6
|
+
"node": ">=22.20.0"
|
|
8
7
|
},
|
|
9
8
|
"module": "dist/index.es.js",
|
|
10
9
|
"main": "lib/index.js",
|
|
@@ -17,10 +16,10 @@
|
|
|
17
16
|
"prepublishOnly": "npm run build"
|
|
18
17
|
},
|
|
19
18
|
"dependencies": {
|
|
20
|
-
"axios": "
|
|
21
|
-
"builtin-modules": "
|
|
22
|
-
"dayjs": "
|
|
23
|
-
"puppeteer": "
|
|
19
|
+
"axios": "1.13.6",
|
|
20
|
+
"builtin-modules": "3.3.0",
|
|
21
|
+
"dayjs": "1.11.20",
|
|
22
|
+
"puppeteer": "24.39.1"
|
|
24
23
|
},
|
|
25
24
|
"devDependencies": {
|
|
26
25
|
"@babel/core": "^7.17.0",
|