visualci-gallery 0.1.0 → 0.2.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.
- checksums.yaml +4 -4
- data/README.md +9 -2
- data/app/assets/javascripts/visualci_gallery.js +1157 -390
- data/lib/visualci/gallery/renderer.rb +26 -3
- data/lib/visualci/gallery/version.rb +1 -1
- data/lib/visualci/gallery.rb +53 -4
- metadata +1 -1
|
@@ -75,37 +75,66 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
75
75
|
};
|
|
76
76
|
var VisualCIGallery = (function () {
|
|
77
77
|
var __defProp = Object.defineProperty;
|
|
78
|
+
var __defProps = Object.defineProperties;
|
|
78
79
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
80
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
79
81
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
82
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
80
83
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
84
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
85
|
+
var __defNormalProp = function (obj, key, value) { return key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value: value }) : obj[key] = value; };
|
|
86
|
+
var __spreadValues = function (a, b) {
|
|
87
|
+
var e_1, _w;
|
|
88
|
+
for (var prop in b || (b = {}))
|
|
89
|
+
if (__hasOwnProp.call(b, prop))
|
|
90
|
+
__defNormalProp(a, prop, b[prop]);
|
|
91
|
+
if (__getOwnPropSymbols)
|
|
92
|
+
try {
|
|
93
|
+
for (var _x = __values(__getOwnPropSymbols(b)), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
94
|
+
var prop = _y.value;
|
|
95
|
+
if (__propIsEnum.call(b, prop))
|
|
96
|
+
__defNormalProp(a, prop, b[prop]);
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
100
|
+
finally {
|
|
101
|
+
try {
|
|
102
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
103
|
+
}
|
|
104
|
+
finally { if (e_1) throw e_1.error; }
|
|
105
|
+
}
|
|
106
|
+
return a;
|
|
107
|
+
};
|
|
108
|
+
var __spreadProps = function (a, b) { return __defProps(a, __getOwnPropDescs(b)); };
|
|
81
109
|
var __export = function (target, all) {
|
|
82
110
|
for (var name in all)
|
|
83
111
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
84
112
|
};
|
|
85
113
|
var __copyProps = function (to, from, except, desc) {
|
|
86
|
-
var
|
|
114
|
+
var e_2, _w;
|
|
87
115
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
88
116
|
var _loop_1 = function (key) {
|
|
89
117
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
90
118
|
__defProp(to, key, { get: function () { return from[key]; }, enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
91
119
|
};
|
|
92
120
|
try {
|
|
93
|
-
for (var
|
|
94
|
-
var key =
|
|
121
|
+
for (var _x = __values(__getOwnPropNames(from)), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
122
|
+
var key = _y.value;
|
|
95
123
|
_loop_1(key);
|
|
96
124
|
}
|
|
97
125
|
}
|
|
98
|
-
catch (
|
|
126
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
99
127
|
finally {
|
|
100
128
|
try {
|
|
101
|
-
if (
|
|
129
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
102
130
|
}
|
|
103
|
-
finally { if (
|
|
131
|
+
finally { if (e_2) throw e_2.error; }
|
|
104
132
|
}
|
|
105
133
|
}
|
|
106
134
|
return to;
|
|
107
135
|
};
|
|
108
136
|
var __toCommonJS = function (mod) { return __copyProps(__defProp({}, "__esModule", { value: true }), mod); };
|
|
137
|
+
var __publicField = function (obj, key, value) { return __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value); };
|
|
109
138
|
// src/index.ts
|
|
110
139
|
var index_exports = {};
|
|
111
140
|
__export(index_exports, {
|
|
@@ -132,38 +161,43 @@ var VisualCIGallery = (function () {
|
|
|
132
161
|
if (extra === void 0) { extra = ""; }
|
|
133
162
|
return "<div class=\"vg-seg".concat(extra, "\" role=\"group\" aria-label=\"Screen size\">") + sizes.map(function (s) { return "<button type=\"button\" data-vg-set-size=\"".concat(s, "\" aria-pressed=\"false\">").concat(SIZE_LABEL[s], "</button>"); }).join("") + "</div>";
|
|
134
163
|
}
|
|
164
|
+
function bytesAttrs(v) {
|
|
165
|
+
var shown = v.thumb ? v.thumb.bytes : v.bytes;
|
|
166
|
+
return (shown !== null ? " data-vg-bytes=\"".concat(shown, "\"") : "") + (v.thumb && v.bytes !== null ? " data-vg-full-bytes=\"".concat(v.bytes, "\"") : "") + (v.url2x && v.bytes2x !== null ? " data-vg-2x-bytes=\"".concat(v.bytes2x, "\"") : "");
|
|
167
|
+
}
|
|
135
168
|
function image(title, v, themes) {
|
|
136
169
|
var alt = "".concat(title, ", ").concat(SIZE_LABEL[v.size].toLowerCase(), ", ").concat(themes.join(" and "));
|
|
137
|
-
return "<img class=\"vg-img\" data-vg-size=\"".concat(v.size, "\" data-vg-theme=\"").concat(themes.join(" "), "\" src=\"").concat(escapeHtml(v.url), "\"") + (v.url2x ? " data-src-2x=\"".concat(escapeHtml(v.url2x), "\"") : "") + " width=\"".concat(v.width, "\" height=\"").concat(v.height, "\" alt=\"").concat(escapeHtml(alt), "\" loading=\"lazy\" decoding=\"async\">");
|
|
170
|
+
return "<img class=\"vg-img\" data-vg-size=\"".concat(v.size, "\" data-vg-theme=\"").concat(themes.join(" "), "\" src=\"").concat(escapeHtml(v.thumb ? v.thumb.url : v.url), "\"") + (v.thumb ? " data-src-full=\"".concat(escapeHtml(v.url), "\"") : "") + (v.url2x ? " data-src-2x=\"".concat(escapeHtml(v.url2x), "\"") : "") + bytesAttrs(v) + " width=\"".concat(v.width, "\" height=\"").concat(v.height, "\" alt=\"").concat(escapeHtml(alt), "\" loading=\"lazy\" decoding=\"async\">");
|
|
138
171
|
}
|
|
139
172
|
function card(sc, sizes, heading, caption, fit) {
|
|
140
|
-
var
|
|
173
|
+
var e_3, _w;
|
|
174
|
+
var _a, _b;
|
|
141
175
|
var imgs = [];
|
|
142
176
|
var shown = [];
|
|
143
177
|
var first = null;
|
|
144
178
|
var _loop_2 = function (size) {
|
|
145
|
-
var
|
|
179
|
+
var e_4, _x;
|
|
146
180
|
var at = sc.variants.filter(function (v) { return v.size === size; });
|
|
147
181
|
if (at.length === 0)
|
|
148
182
|
return "continue";
|
|
149
183
|
shown.push(size);
|
|
150
184
|
first != null ? first : first = at[0];
|
|
151
|
-
if (at[0].url === at[1].url && at[0].url2x === at[1].url2x) {
|
|
185
|
+
if (at[0].url === at[1].url && at[0].url2x === at[1].url2x && ((_a = at[0].thumb) == null ? void 0 : _a.url) === ((_b = at[1].thumb) == null ? void 0 : _b.url)) {
|
|
152
186
|
imgs.push(image(sc.title, at[0], ["light", "dark"]));
|
|
153
187
|
}
|
|
154
188
|
else
|
|
155
189
|
try {
|
|
156
|
-
for (var at_1 = (
|
|
190
|
+
for (var at_1 = (e_4 = void 0, __values(at)), at_1_1 = at_1.next(); !at_1_1.done; at_1_1 = at_1.next()) {
|
|
157
191
|
var v = at_1_1.value;
|
|
158
192
|
imgs.push(image(sc.title, v, [v.theme]));
|
|
159
193
|
}
|
|
160
194
|
}
|
|
161
|
-
catch (
|
|
195
|
+
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
162
196
|
finally {
|
|
163
197
|
try {
|
|
164
|
-
if (at_1_1 && !at_1_1.done && (
|
|
198
|
+
if (at_1_1 && !at_1_1.done && (_x = at_1.return)) _x.call(at_1);
|
|
165
199
|
}
|
|
166
|
-
finally { if (
|
|
200
|
+
finally { if (e_4) throw e_4.error; }
|
|
167
201
|
}
|
|
168
202
|
};
|
|
169
203
|
try {
|
|
@@ -172,22 +206,29 @@ var VisualCIGallery = (function () {
|
|
|
172
206
|
_loop_2(size);
|
|
173
207
|
}
|
|
174
208
|
}
|
|
175
|
-
catch (
|
|
209
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
176
210
|
finally {
|
|
177
211
|
try {
|
|
178
|
-
if (sizes_1_1 && !sizes_1_1.done && (
|
|
212
|
+
if (sizes_1_1 && !sizes_1_1.done && (_w = sizes_1.return)) _w.call(sizes_1);
|
|
179
213
|
}
|
|
180
|
-
finally { if (
|
|
214
|
+
finally { if (e_3) throw e_3.error; }
|
|
181
215
|
}
|
|
182
216
|
return "<li class=\"vg-card\" data-vg-screen=\"".concat(escapeHtml(sc.key), "\" data-vg-sizes=\"").concat(shown.join(" "), "\"") + (fit === "contain" ? ' data-vg-fit="contain"' : "") + "><a class=\"vg-thumb\" href=\"".concat(escapeHtml(first.url), "\" data-vg-open aria-label=\"").concat(escapeHtml(sc.title), ": view full size\">") + imgs.join("") + "</a><".concat(heading, " class=\"vg-card-title\">").concat(escapeHtml(sc.title), "</").concat(heading, ">") + (caption && sc.caption !== null ? "<p class=\"vg-caption\">".concat(escapeHtml(sc.caption), "</p>") : "") + "</li>";
|
|
183
217
|
}
|
|
218
|
+
function preloadAttr(p) {
|
|
219
|
+
if (p === null)
|
|
220
|
+
return "";
|
|
221
|
+
if (p === "off")
|
|
222
|
+
return ' data-vg-preload="off"';
|
|
223
|
+
return " data-vg-preload=\"fold=".concat(p.fold, " count=").concat(p.count, " bytes=").concat(p.bytes, " parallel=").concat(p.parallel, "\"");
|
|
224
|
+
}
|
|
184
225
|
function render(model) {
|
|
185
226
|
var id = escapeHtml(model.id);
|
|
186
227
|
var h = function (offset) { return "h".concat(Math.min(model.headingLevel + offset, 6)); };
|
|
187
228
|
var below = model.title === null ? 0 : 1;
|
|
188
229
|
var out = [];
|
|
189
230
|
var size = model.layout === "strip" ? stripSize(model) : model.groups[0].sizes[0];
|
|
190
|
-
out.push("<section class=\"vg\" data-vg data-vg-layout=\"".concat(model.layout, "\" aria-label=\"").concat(escapeHtml(model.label), "\" data-vg-size=\"").concat(size, "\"") + (model.themeSwitch ? "" : ' data-vg-theme-source="page"') + ">");
|
|
231
|
+
out.push("<section class=\"vg\" data-vg data-vg-layout=\"".concat(model.layout, "\" aria-label=\"").concat(escapeHtml(model.label), "\" data-vg-size=\"").concat(size, "\"") + (model.themeSwitch ? "" : ' data-vg-theme-source="page"') + preloadAttr(model.preload) + ">");
|
|
191
232
|
if (model.title !== null)
|
|
192
233
|
out.push("<".concat(h(0), " class=\"vg-title\">").concat(escapeHtml(model.title), "</").concat(h(0), ">"));
|
|
193
234
|
if (model.layout === "strip")
|
|
@@ -217,23 +258,23 @@ var VisualCIGallery = (function () {
|
|
|
217
258
|
out.push("</div>");
|
|
218
259
|
}
|
|
219
260
|
model.groups.forEach(function (g, i) {
|
|
220
|
-
var
|
|
261
|
+
var e_5, _w;
|
|
221
262
|
out.push("<div class=\"vg-panel\" id=\"".concat(id, "-panel-").concat(g.slug, "\" data-vg-sizes=\"").concat(g.sizes.join(" "), "\"") + (tabs ? " role=\"tabpanel\" aria-labelledby=\"".concat(id, "-tab-").concat(g.slug, "\"") : "") + (i > 0 ? " hidden" : "") + ">");
|
|
222
263
|
var controls = (model.themeSwitch ? themeSwitch() : "") + (g.sizes.length > 1 ? sizeSwitch(g.sizes) : "");
|
|
223
264
|
out.push("<div class=\"vg-bar\"><".concat(gh, " class=\"vg-group-title\">").concat(escapeHtml(g.title), "</").concat(gh, ">") + (controls ? "<div class=\"vg-controls\">".concat(controls, "</div>") : "") + "</div>");
|
|
224
265
|
out.push('<ul class="vg-grid">');
|
|
225
266
|
try {
|
|
226
|
-
for (var
|
|
227
|
-
var sc =
|
|
267
|
+
for (var _x = __values(g.screens), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
268
|
+
var sc = _y.value;
|
|
228
269
|
out.push(card(sc, g.sizes, ch, true, g.fit));
|
|
229
270
|
}
|
|
230
271
|
}
|
|
231
|
-
catch (
|
|
272
|
+
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
232
273
|
finally {
|
|
233
274
|
try {
|
|
234
|
-
if (
|
|
275
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
235
276
|
}
|
|
236
|
-
finally { if (
|
|
277
|
+
finally { if (e_5) throw e_5.error; }
|
|
237
278
|
}
|
|
238
279
|
out.push("</ul>");
|
|
239
280
|
out.push("</div>");
|
|
@@ -243,43 +284,920 @@ var VisualCIGallery = (function () {
|
|
|
243
284
|
return model.groups.some(function (g) { return g.sizes.includes("desktop"); }) ? "desktop" : "phone";
|
|
244
285
|
}
|
|
245
286
|
function strip(model, id, ch, out) {
|
|
246
|
-
var
|
|
287
|
+
var e_6, _w, e_7, _x;
|
|
247
288
|
var size = stripSize(model);
|
|
248
289
|
out.push("<div class=\"vg-panel\" id=\"".concat(id, "-strip\" data-vg-sizes=\"").concat(size, "\">"));
|
|
249
290
|
out.push('<div class="vg-strip"><button type="button" class="vg-icon vg-strip-prev" data-vg-scroll="-1" aria-label="Scroll back">\u2039</button>');
|
|
250
291
|
out.push('<ul class="vg-grid vg-track">');
|
|
251
292
|
try {
|
|
252
|
-
for (var
|
|
253
|
-
var g =
|
|
293
|
+
for (var _y = __values(model.groups), _z = _y.next(); !_z.done; _z = _y.next()) {
|
|
294
|
+
var g = _z.value;
|
|
254
295
|
try {
|
|
255
|
-
for (var
|
|
256
|
-
var sc =
|
|
296
|
+
for (var _0 = (e_7 = void 0, __values(g.screens)), _1 = _0.next(); !_1.done; _1 = _0.next()) {
|
|
297
|
+
var sc = _1.value;
|
|
257
298
|
if (sc.variants.some(function (v) { return v.size === size; }))
|
|
258
299
|
out.push(card(sc, [size], ch, false, g.fit));
|
|
259
300
|
}
|
|
260
301
|
}
|
|
261
|
-
catch (
|
|
302
|
+
catch (e_7_1) { e_7 = { error: e_7_1 }; }
|
|
262
303
|
finally {
|
|
263
304
|
try {
|
|
264
|
-
if (
|
|
305
|
+
if (_1 && !_1.done && (_x = _0.return)) _x.call(_0);
|
|
265
306
|
}
|
|
266
|
-
finally { if (
|
|
307
|
+
finally { if (e_7) throw e_7.error; }
|
|
267
308
|
}
|
|
268
309
|
}
|
|
269
310
|
}
|
|
270
|
-
catch (
|
|
311
|
+
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
271
312
|
finally {
|
|
272
313
|
try {
|
|
273
|
-
if (
|
|
314
|
+
if (_z && !_z.done && (_w = _y.return)) _w.call(_y);
|
|
274
315
|
}
|
|
275
|
-
finally { if (
|
|
316
|
+
finally { if (e_6) throw e_6.error; }
|
|
276
317
|
}
|
|
277
318
|
out.push("</ul>");
|
|
278
319
|
out.push('<button type="button" class="vg-icon vg-strip-next" data-vg-scroll="1" aria-label="Scroll forward">\u203A</button></div>');
|
|
279
320
|
out.push("</div>");
|
|
280
321
|
}
|
|
322
|
+
// src/model.ts
|
|
323
|
+
var PRELOAD_DEFAULTS = { fold: 250, count: 500, bytes: 5e7, parallel: 4 };
|
|
324
|
+
var PRELOAD_KEYS = ["fold", "count", "bytes", "parallel"];
|
|
325
|
+
var MAX_CAP = 1e12;
|
|
326
|
+
var DEFAULT_TITLE = "Screenshots";
|
|
327
|
+
var SIZES = ["desktop", "phone"];
|
|
328
|
+
var THEMES = ["light", "dark"];
|
|
329
|
+
var EXTENSION = /\.(?:[pP][nN][gG]|[jJ][pP][eE]?[gG]|[wW][eE][bB][pP])$/;
|
|
330
|
+
var WIDTH_THEME = /^([0-9]+)-(light|dark)(-2x)?$/;
|
|
331
|
+
var SCREEN_THEME = /^([\s\S]+?)-(light|dark)(?:-([0-9]+))?(-2x)?$/;
|
|
332
|
+
var SEE_ALL_TEXT = "See all screenshots";
|
|
333
|
+
function parseShot(name, width, height, size) {
|
|
334
|
+
var parts = name.replace(EXTENSION, "").split("/");
|
|
335
|
+
var last = parts.pop();
|
|
336
|
+
var folder = parts.join("/");
|
|
337
|
+
var sized = function (w) { return w !== void 0 ? Number(w) < 768 ? "phone" : "desktop" : size != null ? size : height > width ? "phone" : "desktop"; };
|
|
338
|
+
var css = function (w) { return w !== void 0 ? Number(w) : null; };
|
|
339
|
+
var m = WIDTH_THEME.exec(last);
|
|
340
|
+
if (m && folder) {
|
|
341
|
+
return { key: folder, theme: m[2], size: sized(m[1]), x2: !!m[3], cssWidth: css(m[1]) };
|
|
342
|
+
}
|
|
343
|
+
m = SCREEN_THEME.exec(last);
|
|
344
|
+
if (m) {
|
|
345
|
+
var key = folder ? "".concat(folder, "/").concat(m[1]) : m[1];
|
|
346
|
+
return { key: key, theme: m[2], size: sized(m[3]), x2: !!m[4], cssWidth: css(m[3]) };
|
|
347
|
+
}
|
|
348
|
+
return { key: folder ? "".concat(folder, "/").concat(last) : last, theme: null, size: sized(void 0), x2: false, cssWidth: null };
|
|
349
|
+
}
|
|
350
|
+
function humanize(segments) {
|
|
351
|
+
var text = segments.map(function (s) { return s.replace(/[-_]+/g, " ").replace(/^ +| +$/g, ""); }).join(", ");
|
|
352
|
+
var first = text.codePointAt(0);
|
|
353
|
+
if (first === void 0)
|
|
354
|
+
return text;
|
|
355
|
+
var head = String.fromCodePoint(first);
|
|
356
|
+
return head.toUpperCase() + text.slice(head.length);
|
|
357
|
+
}
|
|
358
|
+
function slugify(name) {
|
|
359
|
+
return name.replace(/[A-Z]/g, function (c) { return c.toLowerCase(); }).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "group";
|
|
360
|
+
}
|
|
361
|
+
function commonFolder(keys) {
|
|
362
|
+
var e_8, _w;
|
|
363
|
+
var folders = keys.map(function (k) { return k.split("/").slice(0, -1); });
|
|
364
|
+
if (folders.length === 0)
|
|
365
|
+
return [];
|
|
366
|
+
var common = folders[0];
|
|
367
|
+
try {
|
|
368
|
+
for (var _x = __values(folders.slice(1)), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
369
|
+
var f = _y.value;
|
|
370
|
+
var i = 0;
|
|
371
|
+
while (i < common.length && i < f.length && common[i] === f[i])
|
|
372
|
+
i++;
|
|
373
|
+
common = common.slice(0, i);
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
catch (e_8_1) { e_8 = { error: e_8_1 }; }
|
|
377
|
+
finally {
|
|
378
|
+
try {
|
|
379
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
380
|
+
}
|
|
381
|
+
finally { if (e_8) throw e_8.error; }
|
|
382
|
+
}
|
|
383
|
+
return common;
|
|
384
|
+
}
|
|
385
|
+
function rankBy(order2) {
|
|
386
|
+
var list = order2 != null ? order2 : [];
|
|
387
|
+
return function (key) {
|
|
388
|
+
var i = list.indexOf(key);
|
|
389
|
+
return i === -1 ? list.length : i;
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
function compare(a, b) {
|
|
393
|
+
var x = Array.from(a, function (c) { return c.codePointAt(0); });
|
|
394
|
+
var y = Array.from(b, function (c) { return c.codePointAt(0); });
|
|
395
|
+
for (var i = 0; i < Math.min(x.length, y.length); i++)
|
|
396
|
+
if (x[i] !== y[i])
|
|
397
|
+
return x[i] - y[i];
|
|
398
|
+
return x.length - y.length;
|
|
399
|
+
}
|
|
400
|
+
var ABSOLUTE = /^[hH][tT][tT][pP][sS]?:\/\/[^\x00-\x20\x7f]+$/;
|
|
401
|
+
function safeHref(value) {
|
|
402
|
+
return ABSOLUTE.test(value) || value !== "" && !/[\x00-\x20\x7f]/.test(value) && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
403
|
+
}
|
|
404
|
+
var ID = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
405
|
+
function fail(message) {
|
|
406
|
+
throw new Error(message);
|
|
407
|
+
}
|
|
408
|
+
var isObject = function (v) { return typeof v === "object" && v !== null && !Array.isArray(v); };
|
|
409
|
+
var MAX_SIZE = 1e6;
|
|
410
|
+
var isSize = function (v) { return typeof v === "number" && Number.isInteger(v) && v > 0 && v <= MAX_SIZE; };
|
|
411
|
+
function opt(value, check, what) {
|
|
412
|
+
if (value === null || value === void 0)
|
|
413
|
+
return void 0;
|
|
414
|
+
if (!check(value))
|
|
415
|
+
fail("gallery option ".concat(what, " is invalid"));
|
|
416
|
+
return value;
|
|
417
|
+
}
|
|
418
|
+
var isString = function (v) { return typeof v === "string"; };
|
|
419
|
+
var isBytes = function (v) { return typeof v === "number" && Number.isInteger(v) && v >= 0 && v <= 1e12; };
|
|
420
|
+
var isStrings = function (v) { return Array.isArray(v) && v.every(isString); };
|
|
421
|
+
var isTexts = function (keys) { return function (v) { return isObject(v) && Object.values(v).every(function (entry) { return isObject(entry) && Object.entries(entry).every(function (_w) {
|
|
422
|
+
var _x = __read(_w, 2), k = _x[0], x = _x[1];
|
|
423
|
+
return keys.includes(k) && (x === null || isString(x));
|
|
424
|
+
}); }); }; };
|
|
425
|
+
function checkManifest(manifest) {
|
|
426
|
+
if (!isObject(manifest) || !Array.isArray(manifest.groups))
|
|
427
|
+
fail("not a gallery manifest: it has no groups");
|
|
428
|
+
manifest.groups.forEach(function (g, i) {
|
|
429
|
+
if (!isObject(g) || typeof g.name !== "string" || g.name === "")
|
|
430
|
+
fail("gallery manifest group ".concat(i, " has no name"));
|
|
431
|
+
if (g.title !== void 0 && g.title !== null && typeof g.title !== "string")
|
|
432
|
+
fail("gallery manifest group ".concat(g.name, ": its title isn't a string"));
|
|
433
|
+
if (!Array.isArray(g.items))
|
|
434
|
+
fail("gallery manifest group ".concat(g.name, " has no items"));
|
|
435
|
+
g.items.forEach(function (item, j) {
|
|
436
|
+
var where = "gallery manifest group ".concat(g.name, ", item ").concat(j);
|
|
437
|
+
if (!isObject(item) || typeof item.name !== "string" || item.name === "")
|
|
438
|
+
fail("".concat(where, " has no name"));
|
|
439
|
+
if (typeof item.url !== "string" || !ABSOLUTE.test(item.url))
|
|
440
|
+
fail("".concat(where, " (").concat(item.name, "): its url isn't an http(s) URL"));
|
|
441
|
+
if (!isSize(item.width) || !isSize(item.height))
|
|
442
|
+
fail("".concat(where, " (").concat(item.name, "): its width and height aren't whole numbers from 1 to 1000000"));
|
|
443
|
+
if (item.bytes !== void 0 && item.bytes !== null && !isBytes(item.bytes))
|
|
444
|
+
fail("".concat(where, " (").concat(item.name, "): its bytes isn't a whole number"));
|
|
445
|
+
var t = item.thumb;
|
|
446
|
+
if (t !== void 0 && t !== null) {
|
|
447
|
+
if (!isObject(t) || typeof t.url !== "string" || !ABSOLUTE.test(t.url) || !isSize(t.width) || !isSize(t.height) || t.bytes !== void 0 && t.bytes !== null && !isBytes(t.bytes)) {
|
|
448
|
+
fail("".concat(where, " (").concat(item.name, "): its thumb needs an http(s) url, a width and a height"));
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
});
|
|
452
|
+
});
|
|
453
|
+
}
|
|
454
|
+
function buildModel(manifest, options) {
|
|
455
|
+
var e_9, _w;
|
|
456
|
+
if (options === void 0) { options = {}; }
|
|
457
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
458
|
+
checkManifest(manifest);
|
|
459
|
+
if (!isObject(options))
|
|
460
|
+
fail("gallery options must be an object");
|
|
461
|
+
var o = options;
|
|
462
|
+
var level = (_a = opt(o.headingLevel, function (v) { return Number.isInteger(v); }, "headingLevel")) != null ? _a : 2;
|
|
463
|
+
var headingLevel = Math.min(Math.max(level, 1), 4);
|
|
464
|
+
var title = o.title === void 0 ? DEFAULT_TITLE : (_b = opt(o.title, isString, "title")) != null ? _b : null;
|
|
465
|
+
var id = (_c = opt(o.id, function (v) { return isString(v) && ID.test(v); }, "id")) != null ? _c : "vg";
|
|
466
|
+
var screensOpt = (_d = opt(o.screens, isTexts(["title", "caption"]), "screens")) != null ? _d : {};
|
|
467
|
+
var groupsOpt = (_e = opt(o.groups, function (v) { return isObject(v) && Object.values(v).every(function (entry) { return isObject(entry) && Object.entries(entry).every(function (_w) {
|
|
468
|
+
var _x = __read(_w, 2), k = _x[0], x = _x[1];
|
|
469
|
+
return k === "title" && (x === null || isString(x)) || k === "size" && (x === null || SIZES.includes(x)) || k === "fit" && (x === null || x === "cover" || x === "contain");
|
|
470
|
+
}); }); }, "groups")) != null ? _e : {};
|
|
471
|
+
var order2 = opt(o.order, isStrings, "order");
|
|
472
|
+
var groupOrder = opt(o.groupOrder, isStrings, "groupOrder");
|
|
473
|
+
var credit = (_f = opt(o.credit, function (v) { return typeof v === "boolean"; }, "credit")) != null ? _f : true;
|
|
474
|
+
var themeSwitchOpt = (_g = opt(o.themeSwitch, function (v) { return typeof v === "boolean"; }, "themeSwitch")) != null ? _g : true;
|
|
475
|
+
var layout = (_h = opt(o.layout, function (v) { return v === "grid" || v === "strip"; }, "layout")) != null ? _h : "grid";
|
|
476
|
+
var seeAllOpt = opt(o.seeAll, function (v) { return isObject(v) && isString(v.href) && safeHref(v.href) && (v.text === void 0 || v.text === null || isString(v.text)); }, "seeAll");
|
|
477
|
+
var preloadOpt = opt(o.preload, function (v) { return typeof v === "boolean" || isObject(v) && Object.entries(v).every(function (_w) {
|
|
478
|
+
var _x = __read(_w, 2), k = _x[0], x = _x[1];
|
|
479
|
+
return PRELOAD_KEYS.includes(k) && (x === null || typeof x === "number" && Number.isInteger(x) && x >= (k === "parallel" ? 1 : 0) && x <= (k === "parallel" ? 8 : MAX_CAP));
|
|
480
|
+
}); }, "preload");
|
|
481
|
+
var preload = preloadOpt === void 0 || preloadOpt === true ? null : preloadOpt === false ? "off" : {
|
|
482
|
+
fold: (_i = preloadOpt.fold) != null ? _i : PRELOAD_DEFAULTS.fold,
|
|
483
|
+
count: (_j = preloadOpt.count) != null ? _j : PRELOAD_DEFAULTS.count,
|
|
484
|
+
bytes: (_k = preloadOpt.bytes) != null ? _k : PRELOAD_DEFAULTS.bytes,
|
|
485
|
+
parallel: (_l = preloadOpt.parallel) != null ? _l : PRELOAD_DEFAULTS.parallel
|
|
486
|
+
};
|
|
487
|
+
var slugs = /* @__PURE__ */ new Set();
|
|
488
|
+
var groups = [];
|
|
489
|
+
var _loop_3 = function (g) {
|
|
490
|
+
var e_10, _z, e_11, _0, e_12, _1, e_13, _2;
|
|
491
|
+
var groupSet = Object.prototype.hasOwnProperty.call(groupsOpt, g.name) ? groupsOpt[g.name] : void 0;
|
|
492
|
+
var screens = /* @__PURE__ */ new Map();
|
|
493
|
+
try {
|
|
494
|
+
for (var _3 = (e_10 = void 0, __values(g.items)), _4 = _3.next(); !_4.done; _4 = _3.next()) {
|
|
495
|
+
var item = _4.value;
|
|
496
|
+
var shot = parseShot(item.name, item.width, item.height, (_m = groupSet == null ? void 0 : groupSet.size) != null ? _m : void 0);
|
|
497
|
+
var variants = (_n = screens.get(shot.key)) != null ? _n : /* @__PURE__ */ new Map();
|
|
498
|
+
screens.set(shot.key, variants);
|
|
499
|
+
try {
|
|
500
|
+
for (var _5 = (e_11 = void 0, __values(shot.theme ? [shot.theme] : THEMES)), _6 = _5.next(); !_6.done; _6 = _5.next()) {
|
|
501
|
+
var theme = _6.value;
|
|
502
|
+
var vid = "".concat(shot.size, "-").concat(theme);
|
|
503
|
+
var v = (_o = variants.get(vid)) != null ? _o : {
|
|
504
|
+
size: shot.size,
|
|
505
|
+
theme: theme,
|
|
506
|
+
url: "",
|
|
507
|
+
url2x: null,
|
|
508
|
+
width: 0,
|
|
509
|
+
height: 0,
|
|
510
|
+
bytes: null,
|
|
511
|
+
bytes2x: null,
|
|
512
|
+
thumb: null
|
|
513
|
+
};
|
|
514
|
+
if (shot.x2) {
|
|
515
|
+
if (v.url2x === null) {
|
|
516
|
+
v.url2x = item.url;
|
|
517
|
+
v.bytes2x = (_p = item.bytes) != null ? _p : null;
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
else if (v.url === "") {
|
|
521
|
+
var scaled = shot.cssWidth !== null && item.width > shot.cssWidth;
|
|
522
|
+
var width = scaled ? shot.cssWidth : item.width;
|
|
523
|
+
var height = scaled ? Math.floor((2 * item.height * shot.cssWidth + item.width) / (2 * item.width)) : item.height;
|
|
524
|
+
var t = item.thumb;
|
|
525
|
+
var thumb2 = t ? { url: t.url, width: t.width, height: t.height, bytes: (_q = t.bytes) != null ? _q : null } : null;
|
|
526
|
+
Object.assign(v, { url: item.url, width: width, height: height, bytes: (_r = item.bytes) != null ? _r : null, thumb: thumb2 });
|
|
527
|
+
}
|
|
528
|
+
variants.set(vid, v);
|
|
529
|
+
}
|
|
530
|
+
}
|
|
531
|
+
catch (e_11_1) { e_11 = { error: e_11_1 }; }
|
|
532
|
+
finally {
|
|
533
|
+
try {
|
|
534
|
+
if (_6 && !_6.done && (_0 = _5.return)) _0.call(_5);
|
|
535
|
+
}
|
|
536
|
+
finally { if (e_11) throw e_11.error; }
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
}
|
|
540
|
+
catch (e_10_1) { e_10 = { error: e_10_1 }; }
|
|
541
|
+
finally {
|
|
542
|
+
try {
|
|
543
|
+
if (_4 && !_4.done && (_z = _3.return)) _z.call(_3);
|
|
544
|
+
}
|
|
545
|
+
finally { if (e_10) throw e_10.error; }
|
|
546
|
+
}
|
|
547
|
+
var kept = __spreadArray([], __read(screens), false).map(function (_w) {
|
|
548
|
+
var _x = __read(_w, 2), key = _x[0], variants = _x[1];
|
|
549
|
+
return ({
|
|
550
|
+
key: key,
|
|
551
|
+
variants: __spreadArray([], __read(variants.values()), false).filter(function (v) { return v.url !== ""; }).sort(function (a, b) { return SIZES.indexOf(a.size) - SIZES.indexOf(b.size) || THEMES.indexOf(a.theme) - THEMES.indexOf(b.theme); })
|
|
552
|
+
});
|
|
553
|
+
}).filter(function (sc) { return sc.variants.length > 0; });
|
|
554
|
+
try {
|
|
555
|
+
for (var kept_1 = (e_12 = void 0, __values(kept)), kept_1_1 = kept_1.next(); !kept_1_1.done; kept_1_1 = kept_1.next()) {
|
|
556
|
+
var sc = kept_1_1.value;
|
|
557
|
+
var _loop_4 = function (v) {
|
|
558
|
+
if (!sc.variants.some(function (o2) { return o2.size === v.size && o2.theme !== v.theme; })) {
|
|
559
|
+
fail("gallery screen ".concat(sc.key, " in group ").concat(g.name, " has a ").concat(v.theme, " ").concat(v.size, " screenshot but no ").concat(v.theme === "light" ? "dark" : "light", " one"));
|
|
560
|
+
}
|
|
561
|
+
};
|
|
562
|
+
try {
|
|
563
|
+
for (var _7 = (e_13 = void 0, __values(sc.variants)), _8 = _7.next(); !_8.done; _8 = _7.next()) {
|
|
564
|
+
var v = _8.value;
|
|
565
|
+
_loop_4(v);
|
|
566
|
+
}
|
|
567
|
+
}
|
|
568
|
+
catch (e_13_1) { e_13 = { error: e_13_1 }; }
|
|
569
|
+
finally {
|
|
570
|
+
try {
|
|
571
|
+
if (_8 && !_8.done && (_2 = _7.return)) _2.call(_7);
|
|
572
|
+
}
|
|
573
|
+
finally { if (e_13) throw e_13.error; }
|
|
574
|
+
}
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
catch (e_12_1) { e_12 = { error: e_12_1 }; }
|
|
578
|
+
finally {
|
|
579
|
+
try {
|
|
580
|
+
if (kept_1_1 && !kept_1_1.done && (_1 = kept_1.return)) _1.call(kept_1);
|
|
581
|
+
}
|
|
582
|
+
finally { if (e_12) throw e_12.error; }
|
|
583
|
+
}
|
|
584
|
+
if (kept.length === 0)
|
|
585
|
+
return "continue";
|
|
586
|
+
var prefix = commonFolder(kept.map(function (sc) { return sc.key; })).length;
|
|
587
|
+
var rank = rankBy(order2);
|
|
588
|
+
var list = kept.map(function (_w) {
|
|
589
|
+
var key = _w.key, variants = _w.variants;
|
|
590
|
+
var _a2, _b2;
|
|
591
|
+
var set = Object.prototype.hasOwnProperty.call(screensOpt, key) ? screensOpt[key] : void 0;
|
|
592
|
+
return {
|
|
593
|
+
key: key,
|
|
594
|
+
title: (_a2 = set == null ? void 0 : set.title) != null ? _a2 : humanize(key.split("/").slice(prefix)),
|
|
595
|
+
caption: (_b2 = set == null ? void 0 : set.caption) != null ? _b2 : null,
|
|
596
|
+
variants: variants
|
|
597
|
+
};
|
|
598
|
+
}).sort(function (a, b) { return rank(a.key) - rank(b.key) || compare(a.key, b.key); });
|
|
599
|
+
var slug = slugify(g.name);
|
|
600
|
+
for (var n = 2; slugs.has(slug); n++)
|
|
601
|
+
slug = "".concat(slugify(g.name), "-").concat(n);
|
|
602
|
+
slugs.add(slug);
|
|
603
|
+
groups.push({
|
|
604
|
+
name: g.name,
|
|
605
|
+
title: (_t = (_s = groupSet == null ? void 0 : groupSet.title) != null ? _s : g.title) != null ? _t : g.name,
|
|
606
|
+
slug: slug,
|
|
607
|
+
fit: (_u = groupSet == null ? void 0 : groupSet.fit) != null ? _u : "cover",
|
|
608
|
+
sizes: SIZES.filter(function (sz) { return list.some(function (sc) { return sc.variants.some(function (v) { return v.size === sz; }); }); }),
|
|
609
|
+
screens: list
|
|
610
|
+
});
|
|
611
|
+
};
|
|
612
|
+
try {
|
|
613
|
+
for (var _x = __values(manifest.groups), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
614
|
+
var g = _y.value;
|
|
615
|
+
_loop_3(g);
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
catch (e_9_1) { e_9 = { error: e_9_1 }; }
|
|
619
|
+
finally {
|
|
620
|
+
try {
|
|
621
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
622
|
+
}
|
|
623
|
+
finally { if (e_9) throw e_9.error; }
|
|
624
|
+
}
|
|
625
|
+
if (groups.length === 0)
|
|
626
|
+
fail("the gallery manifest has no screenshots to show");
|
|
627
|
+
var groupRank = rankBy(groupOrder);
|
|
628
|
+
groups.sort(function (a, b) { return groupRank(a.name) - groupRank(b.name); });
|
|
629
|
+
return {
|
|
630
|
+
layout: layout,
|
|
631
|
+
themeSwitch: layout === "grid" && themeSwitchOpt,
|
|
632
|
+
seeAll: seeAllOpt ? { href: seeAllOpt.href, text: (_v = seeAllOpt.text) != null ? _v : SEE_ALL_TEXT } : null,
|
|
633
|
+
title: title,
|
|
634
|
+
label: title != null ? title : DEFAULT_TITLE,
|
|
635
|
+
headingLevel: headingLevel,
|
|
636
|
+
id: id,
|
|
637
|
+
credit: credit,
|
|
638
|
+
preload: preload,
|
|
639
|
+
groups: groups
|
|
640
|
+
};
|
|
641
|
+
}
|
|
642
|
+
// src/preload.ts
|
|
643
|
+
var DEFAULT_CAPS = __spreadValues({}, PRELOAD_DEFAULTS);
|
|
644
|
+
var SLOW_PARALLEL = 2;
|
|
645
|
+
function estimateBytes(width, height) {
|
|
646
|
+
return Math.round(width * height * 0.1);
|
|
647
|
+
}
|
|
648
|
+
var other = function (t) { return t === "light" ? "dark" : "light"; };
|
|
649
|
+
function thumb(img, always) {
|
|
650
|
+
return { url: img.url, bytes: img.bytes, always: always };
|
|
651
|
+
}
|
|
652
|
+
function fullOf(img, _hiDpi) {
|
|
653
|
+
return img.full ? { url: img.full, bytes: img.fullBytes, always: false } : thumb(img, false);
|
|
654
|
+
}
|
|
655
|
+
function othersFrom(tabs, current) {
|
|
656
|
+
var out = [];
|
|
657
|
+
for (var i = 1; i < tabs.length; i++)
|
|
658
|
+
out.push((current + i) % tabs.length);
|
|
659
|
+
return out;
|
|
660
|
+
}
|
|
661
|
+
function order(tabs, current) {
|
|
662
|
+
var e_14, _w, e_15, _x;
|
|
663
|
+
var shown = tabs[current];
|
|
664
|
+
if (!shown)
|
|
665
|
+
return [];
|
|
666
|
+
var rest = othersFrom(tabs, current);
|
|
667
|
+
var out = [];
|
|
668
|
+
shown.cards.forEach(function (card2, i) {
|
|
669
|
+
if (i < shown.fold)
|
|
670
|
+
out.push({ card: card2, fold: true });
|
|
671
|
+
});
|
|
672
|
+
shown.cards.forEach(function (card2, i) {
|
|
673
|
+
if (i >= shown.fold)
|
|
674
|
+
out.push({ card: card2, fold: false });
|
|
675
|
+
});
|
|
676
|
+
try {
|
|
677
|
+
for (var rest_1 = __values(rest), rest_1_1 = rest_1.next(); !rest_1_1.done; rest_1_1 = rest_1.next()) {
|
|
678
|
+
var t = rest_1_1.value;
|
|
679
|
+
tabs[t].cards.slice(0, tabs[t].fold).forEach(function (card2) { return out.push({ card: card2, fold: false }); });
|
|
680
|
+
}
|
|
681
|
+
}
|
|
682
|
+
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
683
|
+
finally {
|
|
684
|
+
try {
|
|
685
|
+
if (rest_1_1 && !rest_1_1.done && (_w = rest_1.return)) _w.call(rest_1);
|
|
686
|
+
}
|
|
687
|
+
finally { if (e_14) throw e_14.error; }
|
|
688
|
+
}
|
|
689
|
+
try {
|
|
690
|
+
for (var rest_2 = __values(rest), rest_2_1 = rest_2.next(); !rest_2_1.done; rest_2_1 = rest_2.next()) {
|
|
691
|
+
var t = rest_2_1.value;
|
|
692
|
+
tabs[t].cards.slice(tabs[t].fold).forEach(function (card2) { return out.push({ card: card2, fold: false }); });
|
|
693
|
+
}
|
|
694
|
+
}
|
|
695
|
+
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
696
|
+
finally {
|
|
697
|
+
try {
|
|
698
|
+
if (rest_2_1 && !rest_2_1.done && (_x = rest_2.return)) _x.call(rest_2);
|
|
699
|
+
}
|
|
700
|
+
finally { if (e_15) throw e_15.error; }
|
|
701
|
+
}
|
|
702
|
+
return out;
|
|
703
|
+
}
|
|
704
|
+
function plan(input) {
|
|
705
|
+
var e_16, _w, e_17, _x, e_18, _y, e_19, _z, e_20, _0;
|
|
706
|
+
var _a;
|
|
707
|
+
var tabs = input.tabs, current = input.current, theme = input.theme, caps = input.caps, mode = input.mode, hiDpi = input.hiDpi;
|
|
708
|
+
var seq = order(tabs, current);
|
|
709
|
+
var candidates = [];
|
|
710
|
+
if (mode === "light") {
|
|
711
|
+
var shown = tabs[current];
|
|
712
|
+
if (shown)
|
|
713
|
+
try {
|
|
714
|
+
for (var _1 = __values(shown.cards), _2 = _1.next(); !_2.done; _2 = _1.next()) {
|
|
715
|
+
var card2 = _2.value;
|
|
716
|
+
candidates.push(thumb(card2[theme], false));
|
|
717
|
+
}
|
|
718
|
+
}
|
|
719
|
+
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
720
|
+
finally {
|
|
721
|
+
try {
|
|
722
|
+
if (_2 && !_2.done && (_w = _1.return)) _w.call(_1);
|
|
723
|
+
}
|
|
724
|
+
finally { if (e_16) throw e_16.error; }
|
|
725
|
+
}
|
|
726
|
+
shown == null ? void 0 : shown.cards.slice(0, shown.fold).forEach(function (_, i) { return candidates[i].always = true; });
|
|
727
|
+
}
|
|
728
|
+
else {
|
|
729
|
+
try {
|
|
730
|
+
for (var seq_1 = __values(seq), seq_1_1 = seq_1.next(); !seq_1_1.done; seq_1_1 = seq_1.next()) {
|
|
731
|
+
var s = seq_1_1.value;
|
|
732
|
+
candidates.push(thumb(s.card[theme], s.fold));
|
|
733
|
+
}
|
|
734
|
+
}
|
|
735
|
+
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
736
|
+
finally {
|
|
737
|
+
try {
|
|
738
|
+
if (seq_1_1 && !seq_1_1.done && (_x = seq_1.return)) _x.call(seq_1);
|
|
739
|
+
}
|
|
740
|
+
finally { if (e_17) throw e_17.error; }
|
|
741
|
+
}
|
|
742
|
+
try {
|
|
743
|
+
for (var seq_2 = __values(seq), seq_2_1 = seq_2.next(); !seq_2_1.done; seq_2_1 = seq_2.next()) {
|
|
744
|
+
var s = seq_2_1.value;
|
|
745
|
+
candidates.push(thumb(s.card[other(theme)], false));
|
|
746
|
+
}
|
|
747
|
+
}
|
|
748
|
+
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
749
|
+
finally {
|
|
750
|
+
try {
|
|
751
|
+
if (seq_2_1 && !seq_2_1.done && (_y = seq_2.return)) _y.call(seq_2);
|
|
752
|
+
}
|
|
753
|
+
finally { if (e_18) throw e_18.error; }
|
|
754
|
+
}
|
|
755
|
+
try {
|
|
756
|
+
for (var _3 = __values([theme, other(theme)]), _4 = _3.next(); !_4.done; _4 = _3.next()) {
|
|
757
|
+
var t = _4.value;
|
|
758
|
+
try {
|
|
759
|
+
for (var seq_3 = (e_20 = void 0, __values(seq)), seq_3_1 = seq_3.next(); !seq_3_1.done; seq_3_1 = seq_3.next()) {
|
|
760
|
+
var s = seq_3_1.value;
|
|
761
|
+
candidates.push(fullOf(s.card[t], hiDpi));
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
catch (e_20_1) { e_20 = { error: e_20_1 }; }
|
|
765
|
+
finally {
|
|
766
|
+
try {
|
|
767
|
+
if (seq_3_1 && !seq_3_1.done && (_0 = seq_3.return)) _0.call(seq_3);
|
|
768
|
+
}
|
|
769
|
+
finally { if (e_20) throw e_20.error; }
|
|
770
|
+
}
|
|
771
|
+
}
|
|
772
|
+
}
|
|
773
|
+
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
774
|
+
finally {
|
|
775
|
+
try {
|
|
776
|
+
if (_4 && !_4.done && (_z = _3.return)) _z.call(_3);
|
|
777
|
+
}
|
|
778
|
+
finally { if (e_19) throw e_19.error; }
|
|
779
|
+
}
|
|
780
|
+
}
|
|
781
|
+
var spent = (_a = input.spent) != null ? _a : { count: 0, bytes: 0 };
|
|
782
|
+
var left = __spreadProps(__spreadValues({}, caps), { count: caps.count - spent.count, bytes: caps.bytes - spent.bytes });
|
|
783
|
+
var done = input.done;
|
|
784
|
+
return capped(done ? candidates.filter(function (c) { return !done.has(c.url); }) : candidates, left);
|
|
785
|
+
}
|
|
786
|
+
function capped(items, caps) {
|
|
787
|
+
var e_21, _w;
|
|
788
|
+
var seen = /* @__PURE__ */ new Set();
|
|
789
|
+
var out = [];
|
|
790
|
+
var always = 0;
|
|
791
|
+
var count = 0;
|
|
792
|
+
var bytes = 0;
|
|
793
|
+
try {
|
|
794
|
+
for (var items_1 = __values(items), items_1_1 = items_1.next(); !items_1_1.done; items_1_1 = items_1.next()) {
|
|
795
|
+
var item = items_1_1.value;
|
|
796
|
+
if (seen.has(item.url))
|
|
797
|
+
continue;
|
|
798
|
+
seen.add(item.url);
|
|
799
|
+
if (item.always && always < caps.fold) {
|
|
800
|
+
always++;
|
|
801
|
+
out.push(item);
|
|
802
|
+
continue;
|
|
803
|
+
}
|
|
804
|
+
var it = __spreadProps(__spreadValues({}, item), { always: false });
|
|
805
|
+
if (count + 1 > caps.count || bytes + it.bytes > caps.bytes)
|
|
806
|
+
break;
|
|
807
|
+
count++;
|
|
808
|
+
bytes += it.bytes;
|
|
809
|
+
out.push(it);
|
|
810
|
+
}
|
|
811
|
+
}
|
|
812
|
+
catch (e_21_1) { e_21 = { error: e_21_1 }; }
|
|
813
|
+
finally {
|
|
814
|
+
try {
|
|
815
|
+
if (items_1_1 && !items_1_1.done && (_w = items_1.return)) _w.call(items_1);
|
|
816
|
+
}
|
|
817
|
+
finally { if (e_21) throw e_21.error; }
|
|
818
|
+
}
|
|
819
|
+
return out;
|
|
820
|
+
}
|
|
821
|
+
function tabItems(tab, theme, foldOnly) {
|
|
822
|
+
if (foldOnly === void 0) { foldOnly = false; }
|
|
823
|
+
var cards = foldOnly ? tab.cards.slice(0, tab.fold) : tab.cards;
|
|
824
|
+
return cards.map(function (c) { return thumb(c[theme], true); });
|
|
825
|
+
}
|
|
826
|
+
function neighbours(cards, i, theme, hiDpi) {
|
|
827
|
+
var e_22, _w;
|
|
828
|
+
var n = cards.length;
|
|
829
|
+
if (n < 2)
|
|
830
|
+
return [];
|
|
831
|
+
var seen = /* @__PURE__ */ new Set([i]);
|
|
832
|
+
var out = [];
|
|
833
|
+
try {
|
|
834
|
+
for (var _x = __values([1, 2, -1, -2]), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
835
|
+
var by = _y.value;
|
|
836
|
+
var j = ((i + by) % n + n) % n;
|
|
837
|
+
if (seen.has(j))
|
|
838
|
+
continue;
|
|
839
|
+
seen.add(j);
|
|
840
|
+
out.push(__spreadProps(__spreadValues({}, fullOf(cards[j][theme], hiDpi)), { always: true }));
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
catch (e_22_1) { e_22 = { error: e_22_1 }; }
|
|
844
|
+
finally {
|
|
845
|
+
try {
|
|
846
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
847
|
+
}
|
|
848
|
+
finally { if (e_22) throw e_22.error; }
|
|
849
|
+
}
|
|
850
|
+
return out;
|
|
851
|
+
}
|
|
852
|
+
var RECHECK_MS = 15e3;
|
|
853
|
+
var SLOW_RATE = 125e3;
|
|
854
|
+
var RATE_WINDOW = 6;
|
|
855
|
+
var CACHED_MS = 8;
|
|
856
|
+
var Preloader = /** @class */ (function () {
|
|
857
|
+
function Preloader(env, caps, onSpeed) {
|
|
858
|
+
if (onSpeed === void 0) { onSpeed = function () {
|
|
859
|
+
}; }
|
|
860
|
+
__publicField(this, "env", env);
|
|
861
|
+
__publicField(this, "caps", caps);
|
|
862
|
+
__publicField(this, "onSpeed", onSpeed);
|
|
863
|
+
__publicField(this, "queue", []);
|
|
864
|
+
__publicField(this, "front", []);
|
|
865
|
+
__publicField(this, "running", /* @__PURE__ */ new Map());
|
|
866
|
+
__publicField(this, "finished", /* @__PURE__ */ new Set());
|
|
867
|
+
__publicField(this, "samples", []);
|
|
868
|
+
__publicField(this, "stopped", false);
|
|
869
|
+
__publicField(this, "pumping", false);
|
|
870
|
+
__publicField(this, "recheck", RECHECK_MS);
|
|
871
|
+
__publicField(this, "rechecking", false);
|
|
872
|
+
/** Background images loaded past the fold, against the caps. */
|
|
873
|
+
__publicField(this, "spent", { count: 0, bytes: 0 });
|
|
874
|
+
/** Set by a slow measured rate, cleared by a fast one. */
|
|
875
|
+
__publicField(this, "slow", false);
|
|
876
|
+
}
|
|
877
|
+
/** Replaces the background queue. Background requests still running that the new plan doesn't want are dropped. */
|
|
878
|
+
Preloader.prototype.setPlan = function (items) {
|
|
879
|
+
var e_23, _w;
|
|
880
|
+
this.queue = items.slice();
|
|
881
|
+
var wanted = new Set(items.map(function (i) { return i.url; }));
|
|
882
|
+
try {
|
|
883
|
+
for (var _x = __values(this.running.values()), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
884
|
+
var r = _y.value;
|
|
885
|
+
if (!r.front && !wanted.has(r.item.url))
|
|
886
|
+
this.drop(r);
|
|
887
|
+
}
|
|
888
|
+
}
|
|
889
|
+
catch (e_23_1) { e_23 = { error: e_23_1 }; }
|
|
890
|
+
finally {
|
|
891
|
+
try {
|
|
892
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
893
|
+
}
|
|
894
|
+
finally { if (e_23) throw e_23.error; }
|
|
895
|
+
}
|
|
896
|
+
this.schedule();
|
|
897
|
+
this.maybeRecheck();
|
|
898
|
+
};
|
|
899
|
+
/** Puts what the reader did (or is about to do) ahead of everything, replacing the last jump. To make room, the
|
|
900
|
+
* background requests running are dropped first, then the old jump's. */
|
|
901
|
+
Preloader.prototype.jump = function (items, high) {
|
|
902
|
+
var e_24, _w, _x;
|
|
903
|
+
var _this = this;
|
|
904
|
+
this.front = items.filter(function (i) { return !_this.finished.has(i.url); }).map(function (item) { return ({ item: item, high: high }); });
|
|
905
|
+
var wanted = new Set(this.front.map(function (f) { return f.item.url; }));
|
|
906
|
+
var waiting = this.front.filter(function (f) { return !_this.running.has(f.item.url); }).length;
|
|
907
|
+
var free = this.parallel() - this.running.size;
|
|
908
|
+
var victims = __spreadArray([], __read(this.running.values()), false).filter(function (r) { return !wanted.has(r.item.url); }).sort(function (a, b) { return Number(a.front) - Number(b.front); });
|
|
909
|
+
var back = [];
|
|
910
|
+
try {
|
|
911
|
+
for (var victims_1 = __values(victims), victims_1_1 = victims_1.next(); !victims_1_1.done; victims_1_1 = victims_1.next()) {
|
|
912
|
+
var r = victims_1_1.value;
|
|
913
|
+
if (free >= waiting)
|
|
914
|
+
break;
|
|
915
|
+
this.drop(r);
|
|
916
|
+
if (!r.front)
|
|
917
|
+
back.push(r.item);
|
|
918
|
+
free++;
|
|
919
|
+
}
|
|
920
|
+
}
|
|
921
|
+
catch (e_24_1) { e_24 = { error: e_24_1 }; }
|
|
922
|
+
finally {
|
|
923
|
+
try {
|
|
924
|
+
if (victims_1_1 && !victims_1_1.done && (_w = victims_1.return)) _w.call(victims_1);
|
|
925
|
+
}
|
|
926
|
+
finally { if (e_24) throw e_24.error; }
|
|
927
|
+
}
|
|
928
|
+
(_x = this.queue).unshift.apply(_x, __spreadArray([], __read(back), false));
|
|
929
|
+
this.pump();
|
|
930
|
+
};
|
|
931
|
+
/** Adds a likely next step (a tab the pointer is over) after the current jump, without dropping anything. */
|
|
932
|
+
Preloader.prototype.hint = function (items) {
|
|
933
|
+
var e_25, _w;
|
|
934
|
+
var queued = new Set(this.front.map(function (f) { return f.item.url; }));
|
|
935
|
+
try {
|
|
936
|
+
for (var items_2 = __values(items), items_2_1 = items_2.next(); !items_2_1.done; items_2_1 = items_2.next()) {
|
|
937
|
+
var item = items_2_1.value;
|
|
938
|
+
if (!this.finished.has(item.url) && !queued.has(item.url))
|
|
939
|
+
this.front.push({ item: item, high: false });
|
|
940
|
+
}
|
|
941
|
+
}
|
|
942
|
+
catch (e_25_1) { e_25 = { error: e_25_1 }; }
|
|
943
|
+
finally {
|
|
944
|
+
try {
|
|
945
|
+
if (items_2_1 && !items_2_1.done && (_w = items_2.return)) _w.call(items_2);
|
|
946
|
+
}
|
|
947
|
+
finally { if (e_25) throw e_25.error; }
|
|
948
|
+
}
|
|
949
|
+
this.pump();
|
|
950
|
+
};
|
|
951
|
+
/** Every URL loaded so far. */
|
|
952
|
+
Preloader.prototype.loaded = function () {
|
|
953
|
+
return new Set(this.finished);
|
|
954
|
+
};
|
|
955
|
+
Preloader.prototype.has = function (url) {
|
|
956
|
+
return this.finished.has(url);
|
|
957
|
+
};
|
|
958
|
+
/** What's running, for tests. */
|
|
959
|
+
Preloader.prototype.inFlight = function () {
|
|
960
|
+
return __spreadArray([], __read(this.running.keys()), false);
|
|
961
|
+
};
|
|
962
|
+
Preloader.prototype.stop = function () {
|
|
963
|
+
var e_26, _w;
|
|
964
|
+
this.stopped = true;
|
|
965
|
+
try {
|
|
966
|
+
for (var _x = __values(this.running.values()), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
967
|
+
var r = _y.value;
|
|
968
|
+
r.req.cancel();
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
catch (e_26_1) { e_26 = { error: e_26_1 }; }
|
|
972
|
+
finally {
|
|
973
|
+
try {
|
|
974
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
975
|
+
}
|
|
976
|
+
finally { if (e_26) throw e_26.error; }
|
|
977
|
+
}
|
|
978
|
+
this.running.clear();
|
|
979
|
+
this.queue = [];
|
|
980
|
+
this.front = [];
|
|
981
|
+
};
|
|
982
|
+
Preloader.prototype.parallel = function () {
|
|
983
|
+
return this.slow ? Math.min(SLOW_PARALLEL, this.caps.parallel) : this.caps.parallel;
|
|
984
|
+
};
|
|
985
|
+
Preloader.prototype.drop = function (r) {
|
|
986
|
+
r.req.cancel();
|
|
987
|
+
this.running.delete(r.item.url);
|
|
988
|
+
};
|
|
989
|
+
/** The background waits for idle time; a jump starts at once. */
|
|
990
|
+
Preloader.prototype.schedule = function () {
|
|
991
|
+
var _this = this;
|
|
992
|
+
if (this.pumping || this.stopped)
|
|
993
|
+
return;
|
|
994
|
+
this.pumping = true;
|
|
995
|
+
this.env.idle(function () {
|
|
996
|
+
_this.pumping = false;
|
|
997
|
+
_this.pump();
|
|
998
|
+
});
|
|
999
|
+
};
|
|
1000
|
+
Preloader.prototype.next = function () {
|
|
1001
|
+
while (this.front.length) {
|
|
1002
|
+
var f = this.front.shift();
|
|
1003
|
+
if (!this.finished.has(f.item.url) && !this.running.has(f.item.url))
|
|
1004
|
+
return __spreadProps(__spreadValues({}, f), { front: true });
|
|
1005
|
+
}
|
|
1006
|
+
while (this.queue.length) {
|
|
1007
|
+
var item = this.queue.shift();
|
|
1008
|
+
if (!this.finished.has(item.url) && !this.running.has(item.url))
|
|
1009
|
+
return { item: item, high: false, front: false };
|
|
1010
|
+
}
|
|
1011
|
+
return null;
|
|
1012
|
+
};
|
|
1013
|
+
Preloader.prototype.pump = function () {
|
|
1014
|
+
var _this = this;
|
|
1015
|
+
var _loop_5 = function () {
|
|
1016
|
+
var n = this_1.next();
|
|
1017
|
+
if (!n)
|
|
1018
|
+
return { value: void 0 };
|
|
1019
|
+
var req = this_1.env.load(n.item.url, n.high);
|
|
1020
|
+
var r = { item: n.item, high: n.high, front: n.front, req: req };
|
|
1021
|
+
this_1.running.set(n.item.url, r);
|
|
1022
|
+
req.done.then(function (ok) {
|
|
1023
|
+
if (_this.running.get(n.item.url) !== r)
|
|
1024
|
+
return;
|
|
1025
|
+
_this.running.delete(n.item.url);
|
|
1026
|
+
_this.finished.add(n.item.url);
|
|
1027
|
+
if (!n.front && !n.item.always) {
|
|
1028
|
+
_this.spent.count++;
|
|
1029
|
+
_this.spent.bytes += n.item.bytes;
|
|
1030
|
+
}
|
|
1031
|
+
if (ok)
|
|
1032
|
+
_this.measure(n.item);
|
|
1033
|
+
if (_this.front.length)
|
|
1034
|
+
_this.pump();
|
|
1035
|
+
else
|
|
1036
|
+
_this.schedule();
|
|
1037
|
+
_this.maybeRecheck();
|
|
1038
|
+
});
|
|
1039
|
+
};
|
|
1040
|
+
var this_1 = this;
|
|
1041
|
+
while (!this.stopped && this.running.size < this.parallel()) {
|
|
1042
|
+
var state_1 = _loop_5();
|
|
1043
|
+
if (typeof state_1 === "object")
|
|
1044
|
+
return state_1.value;
|
|
1045
|
+
}
|
|
1046
|
+
};
|
|
1047
|
+
/** The rate over the latest finished requests: their bytes over the time from the first start to the last end, so
|
|
1048
|
+
* requests running side by side count once. Cached ones are left out. */
|
|
1049
|
+
Preloader.prototype.measure = function (item) {
|
|
1050
|
+
var _a;
|
|
1051
|
+
var t = this.env.timing(item.url);
|
|
1052
|
+
if (!t || t.end - t.start < CACHED_MS)
|
|
1053
|
+
return;
|
|
1054
|
+
this.samples.push({ start: t.start, end: t.end, bytes: (_a = t.bytes) != null ? _a : item.bytes });
|
|
1055
|
+
if (this.samples.length > RATE_WINDOW)
|
|
1056
|
+
this.samples.shift();
|
|
1057
|
+
if (this.samples.length < Math.min(3, RATE_WINDOW))
|
|
1058
|
+
return;
|
|
1059
|
+
var start = Math.min.apply(Math, __spreadArray([], __read(this.samples.map(function (s) { return s.start; })), false));
|
|
1060
|
+
var end = Math.max.apply(Math, __spreadArray([], __read(this.samples.map(function (s) { return s.end; })), false));
|
|
1061
|
+
var bytes = this.samples.reduce(function (sum, s) { return sum + s.bytes; }, 0);
|
|
1062
|
+
var slow = bytes / ((end - start) / 1e3) < SLOW_RATE;
|
|
1063
|
+
if (slow !== this.slow)
|
|
1064
|
+
this.flip(slow);
|
|
1065
|
+
else if (!slow)
|
|
1066
|
+
this.recheck = RECHECK_MS;
|
|
1067
|
+
};
|
|
1068
|
+
/** A new verdict starts a new window, so old samples never decide the next one. */
|
|
1069
|
+
Preloader.prototype.flip = function (slow) {
|
|
1070
|
+
this.slow = slow;
|
|
1071
|
+
this.samples = [];
|
|
1072
|
+
this.onSpeed(slow);
|
|
1073
|
+
};
|
|
1074
|
+
/** Slow, with nothing left to load: nothing new gets measured, so after a while try the full plan again. If the
|
|
1075
|
+
* rate is still slow the next samples say so, and the wait doubles. */
|
|
1076
|
+
Preloader.prototype.maybeRecheck = function () {
|
|
1077
|
+
var _this = this;
|
|
1078
|
+
if (!this.slow || this.rechecking || this.stopped || this.running.size || this.front.length || this.queue.length)
|
|
1079
|
+
return;
|
|
1080
|
+
this.rechecking = true;
|
|
1081
|
+
var wait = this.recheck;
|
|
1082
|
+
this.recheck *= 2;
|
|
1083
|
+
this.env.later(function () {
|
|
1084
|
+
_this.rechecking = false;
|
|
1085
|
+
if (_this.stopped || !_this.slow)
|
|
1086
|
+
return;
|
|
1087
|
+
_this.flip(false);
|
|
1088
|
+
}, wait);
|
|
1089
|
+
};
|
|
1090
|
+
return Preloader;
|
|
1091
|
+
}());
|
|
281
1092
|
// src/hydrate.ts
|
|
282
1093
|
var hydrated = /* @__PURE__ */ new WeakMap();
|
|
1094
|
+
function preloadCaps(root, option) {
|
|
1095
|
+
var e_27, _w;
|
|
1096
|
+
if (option === false)
|
|
1097
|
+
return null;
|
|
1098
|
+
if (typeof option === "object" && option !== null)
|
|
1099
|
+
return sane(__spreadValues(__spreadValues({}, DEFAULT_CAPS), definedOnly(option)));
|
|
1100
|
+
if (option === true)
|
|
1101
|
+
return __spreadValues({}, DEFAULT_CAPS);
|
|
1102
|
+
var attr = root.getAttribute("data-vg-preload");
|
|
1103
|
+
if (attr === null)
|
|
1104
|
+
return __spreadValues({}, DEFAULT_CAPS);
|
|
1105
|
+
if (attr === "off")
|
|
1106
|
+
return null;
|
|
1107
|
+
var caps = __spreadValues({}, DEFAULT_CAPS);
|
|
1108
|
+
try {
|
|
1109
|
+
for (var _x = __values(attr.split(" ")), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
1110
|
+
var pair = _y.value;
|
|
1111
|
+
var _z = __read(pair.split("="), 2), k = _z[0], v = _z[1];
|
|
1112
|
+
if (k in caps && /^\d+$/.test(v != null ? v : ""))
|
|
1113
|
+
caps[k] = Number(v);
|
|
1114
|
+
}
|
|
1115
|
+
}
|
|
1116
|
+
catch (e_27_1) { e_27 = { error: e_27_1 }; }
|
|
1117
|
+
finally {
|
|
1118
|
+
try {
|
|
1119
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
1120
|
+
}
|
|
1121
|
+
finally { if (e_27) throw e_27.error; }
|
|
1122
|
+
}
|
|
1123
|
+
return sane(caps);
|
|
1124
|
+
}
|
|
1125
|
+
function sane(caps) {
|
|
1126
|
+
return __spreadProps(__spreadValues({}, caps), { parallel: Math.min(Math.max(Math.floor(caps.parallel) || 1, 1), 8) });
|
|
1127
|
+
}
|
|
1128
|
+
function definedOnly(o) {
|
|
1129
|
+
var e_28, _w;
|
|
1130
|
+
var out = {};
|
|
1131
|
+
try {
|
|
1132
|
+
for (var _x = __values(Object.entries(o)), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
1133
|
+
var _z = __read(_y.value, 2), k = _z[0], v = _z[1];
|
|
1134
|
+
if (typeof v === "number")
|
|
1135
|
+
out[k] = v;
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
catch (e_28_1) { e_28 = { error: e_28_1 }; }
|
|
1139
|
+
finally {
|
|
1140
|
+
try {
|
|
1141
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
1142
|
+
}
|
|
1143
|
+
finally { if (e_28) throw e_28.error; }
|
|
1144
|
+
}
|
|
1145
|
+
return out;
|
|
1146
|
+
}
|
|
1147
|
+
function lowData() {
|
|
1148
|
+
var _a;
|
|
1149
|
+
var c = navigator.connection;
|
|
1150
|
+
if ((c == null ? void 0 : c.saveData) || /(^|-)2g$/.test((_a = c == null ? void 0 : c.effectiveType) != null ? _a : ""))
|
|
1151
|
+
return true;
|
|
1152
|
+
return typeof matchMedia === "function" && matchMedia("(prefers-reduced-data: reduce)").matches;
|
|
1153
|
+
}
|
|
1154
|
+
var REQUEST_TIMEOUT_MS = 3e4;
|
|
1155
|
+
function browserEnv() {
|
|
1156
|
+
var clock = /* @__PURE__ */ new Map();
|
|
1157
|
+
var now = function () { return typeof performance !== "undefined" ? performance.now() : Date.now(); };
|
|
1158
|
+
return {
|
|
1159
|
+
load: function (url, high) {
|
|
1160
|
+
var img = new Image();
|
|
1161
|
+
img.decoding = "async";
|
|
1162
|
+
img.fetchPriority = high ? "high" : "low";
|
|
1163
|
+
var settle = function () {
|
|
1164
|
+
};
|
|
1165
|
+
var done = new Promise(function (resolve) { return settle = resolve; });
|
|
1166
|
+
var start = now();
|
|
1167
|
+
img.onload = function () {
|
|
1168
|
+
clock.set(url, { start: start, end: now() });
|
|
1169
|
+
settle(true);
|
|
1170
|
+
};
|
|
1171
|
+
img.onerror = function () { return settle(false); };
|
|
1172
|
+
img.src = url;
|
|
1173
|
+
var cancel = function () {
|
|
1174
|
+
clearTimeout(timer);
|
|
1175
|
+
img.onload = img.onerror = null;
|
|
1176
|
+
img.removeAttribute("src");
|
|
1177
|
+
settle(false);
|
|
1178
|
+
};
|
|
1179
|
+
var timer = setTimeout(cancel, REQUEST_TIMEOUT_MS);
|
|
1180
|
+
done.then(function () { return clearTimeout(timer); });
|
|
1181
|
+
return { done: done, cancel: cancel };
|
|
1182
|
+
},
|
|
1183
|
+
later: function (fn, ms) { return void setTimeout(fn, ms); },
|
|
1184
|
+
idle: function (fn) {
|
|
1185
|
+
if (typeof requestIdleCallback === "function")
|
|
1186
|
+
requestIdleCallback(function () { return fn(); }, { timeout: 2e3 });
|
|
1187
|
+
else
|
|
1188
|
+
setTimeout(fn, 50);
|
|
1189
|
+
},
|
|
1190
|
+
timing: function (url) {
|
|
1191
|
+
var own = clock.get(url);
|
|
1192
|
+
clock.delete(url);
|
|
1193
|
+
var entries = typeof performance !== "undefined" && performance.getEntriesByName ? performance.getEntriesByName(url) : [];
|
|
1194
|
+
var e = entries[entries.length - 1];
|
|
1195
|
+
if (e && e.responseEnd > 0 && (!own || e.startTime >= own.start - 1))
|
|
1196
|
+
return { start: e.startTime, end: e.responseEnd, bytes: e.encodedBodySize > 0 ? e.encodedBodySize : null };
|
|
1197
|
+
return own ? __spreadProps(__spreadValues({}, own), { bytes: null }) : null;
|
|
1198
|
+
}
|
|
1199
|
+
};
|
|
1200
|
+
}
|
|
283
1201
|
function pageTheme() {
|
|
284
1202
|
var set = document.documentElement.getAttribute("data-theme");
|
|
285
1203
|
if (set === "light" || set === "dark")
|
|
@@ -312,9 +1230,10 @@ var VisualCIGallery = (function () {
|
|
|
312
1230
|
function hydratedGallery(root) {
|
|
313
1231
|
return hydrated.get(root);
|
|
314
1232
|
}
|
|
315
|
-
function hydrate(el) {
|
|
316
|
-
var
|
|
317
|
-
|
|
1233
|
+
function hydrate(el, options) {
|
|
1234
|
+
var e_29, _w;
|
|
1235
|
+
if (options === void 0) { options = {}; }
|
|
1236
|
+
var _a, _b;
|
|
318
1237
|
var found = el.matches("[data-vg]") ? el : el.querySelector("[data-vg]");
|
|
319
1238
|
if (!found)
|
|
320
1239
|
throw new Error("hydrate: no gallery markup ([data-vg]) in this element");
|
|
@@ -351,53 +1270,59 @@ var VisualCIGallery = (function () {
|
|
|
351
1270
|
var sizesOf = function (el2) { return listOf(el2 == null ? void 0 : el2.getAttribute("data-vg-sizes")); };
|
|
352
1271
|
var shownIn = function (card2) { return card2.querySelector(".vg-img[data-vg-size=\"".concat(size(), "\"][data-vg-theme~=\"").concat(theme(), "\"]")); };
|
|
353
1272
|
function sync() {
|
|
354
|
-
var
|
|
1273
|
+
var e_30, _w;
|
|
355
1274
|
var _a2;
|
|
356
1275
|
try {
|
|
357
|
-
for (var
|
|
358
|
-
var card2 =
|
|
359
|
-
var
|
|
1276
|
+
for (var _x = __values(all(".vg-card")), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
1277
|
+
var card2 = _y.value;
|
|
1278
|
+
var img = shownIn(card2);
|
|
1279
|
+
var src = (_a2 = img == null ? void 0 : img.getAttribute("data-src-full")) != null ? _a2 : img == null ? void 0 : img.getAttribute("src");
|
|
360
1280
|
var link = card2.querySelector("a.vg-thumb");
|
|
361
1281
|
if (link && src)
|
|
362
1282
|
link.setAttribute("href", src);
|
|
363
1283
|
}
|
|
364
1284
|
}
|
|
365
|
-
catch (
|
|
1285
|
+
catch (e_30_1) { e_30 = { error: e_30_1 }; }
|
|
366
1286
|
finally {
|
|
367
1287
|
try {
|
|
368
|
-
if (
|
|
1288
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
369
1289
|
}
|
|
370
|
-
finally { if (
|
|
1290
|
+
finally { if (e_30) throw e_30.error; }
|
|
371
1291
|
}
|
|
372
1292
|
if (box.open && current)
|
|
373
1293
|
show(current);
|
|
374
1294
|
}
|
|
375
1295
|
function set(key, value) {
|
|
376
|
-
var
|
|
1296
|
+
var e_31, _w;
|
|
377
1297
|
root.setAttribute("data-vg-".concat(key), value);
|
|
378
1298
|
try {
|
|
379
|
-
for (var
|
|
380
|
-
var b =
|
|
1299
|
+
for (var _x = __values(all("[data-vg-set-".concat(key, "]"))), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
1300
|
+
var b = _y.value;
|
|
381
1301
|
b.setAttribute("aria-pressed", String(b.getAttribute("data-vg-set-".concat(key)) === value));
|
|
382
1302
|
}
|
|
383
1303
|
}
|
|
384
|
-
catch (
|
|
1304
|
+
catch (e_31_1) { e_31 = { error: e_31_1 }; }
|
|
385
1305
|
finally {
|
|
386
1306
|
try {
|
|
387
|
-
if (
|
|
1307
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
388
1308
|
}
|
|
389
|
-
finally { if (
|
|
1309
|
+
finally { if (e_31) throw e_31.error; }
|
|
390
1310
|
}
|
|
391
1311
|
sync();
|
|
1312
|
+
if (!selecting)
|
|
1313
|
+
replan();
|
|
392
1314
|
}
|
|
393
1315
|
var chosen = matchMedia("(max-width: 47.99rem)").matches ? "phone" : "desktop";
|
|
394
1316
|
function fit() {
|
|
395
1317
|
var sizes = sizesOf(panel());
|
|
396
1318
|
set("size", sizes.length === 0 || sizes.indexOf(chosen) !== -1 ? chosen : sizes[0]);
|
|
397
1319
|
}
|
|
1320
|
+
var selecting = false;
|
|
398
1321
|
function select(tab, focus) {
|
|
399
|
-
var
|
|
1322
|
+
var e_32, _w;
|
|
400
1323
|
if (focus === void 0) { focus = false; }
|
|
1324
|
+
var changed = tab.getAttribute("aria-selected") !== "true";
|
|
1325
|
+
selecting = true;
|
|
401
1326
|
try {
|
|
402
1327
|
for (var tabs_1 = __values(tabs), tabs_1_1 = tabs_1.next(); !tabs_1_1.done; tabs_1_1 = tabs_1.next()) {
|
|
403
1328
|
var t = tabs_1_1.value;
|
|
@@ -409,41 +1334,47 @@ var VisualCIGallery = (function () {
|
|
|
409
1334
|
p.hidden = !on;
|
|
410
1335
|
}
|
|
411
1336
|
}
|
|
412
|
-
catch (
|
|
1337
|
+
catch (e_32_1) { e_32 = { error: e_32_1 }; }
|
|
413
1338
|
finally {
|
|
414
1339
|
try {
|
|
415
|
-
if (tabs_1_1 && !tabs_1_1.done && (
|
|
1340
|
+
if (tabs_1_1 && !tabs_1_1.done && (_w = tabs_1.return)) _w.call(tabs_1);
|
|
416
1341
|
}
|
|
417
|
-
finally { if (
|
|
1342
|
+
finally { if (e_32) throw e_32.error; }
|
|
418
1343
|
}
|
|
419
1344
|
if (focus)
|
|
420
1345
|
tab.focus();
|
|
421
1346
|
fit();
|
|
1347
|
+
selecting = false;
|
|
1348
|
+
if (preloader && changed) {
|
|
1349
|
+
var t = planTabs();
|
|
1350
|
+
preloader.jump(tabItems(t.tabs[t.current], theme()), true);
|
|
1351
|
+
}
|
|
1352
|
+
replan();
|
|
422
1353
|
}
|
|
423
1354
|
function cards() {
|
|
424
1355
|
return all(".vg-panel:not([hidden]) .vg-card").filter(function (c) { return sizesOf(c).indexOf(size()) !== -1; });
|
|
425
1356
|
}
|
|
426
1357
|
function show(card2) {
|
|
427
|
-
var
|
|
428
|
-
var _a2,
|
|
1358
|
+
var e_33, _w, e_34, _x;
|
|
1359
|
+
var _a2, _b2, _c, _d, _e, _f;
|
|
429
1360
|
current = card2;
|
|
430
|
-
boxTitle.textContent = (
|
|
1361
|
+
boxTitle.textContent = (_b2 = (_a2 = card2.querySelector(".vg-card-title")) == null ? void 0 : _a2.textContent) != null ? _b2 : "";
|
|
431
1362
|
var sizes = sizesOf(card2);
|
|
432
1363
|
var boxSizes = box.querySelector(".vg-box-sizes");
|
|
433
1364
|
if (boxSizes) {
|
|
434
1365
|
boxSizes.hidden = sizes.length < 2;
|
|
435
1366
|
try {
|
|
436
|
-
for (var
|
|
437
|
-
var b =
|
|
1367
|
+
for (var _y = __values(toArray(boxSizes.querySelectorAll("[data-vg-set-size]"))), _z = _y.next(); !_z.done; _z = _y.next()) {
|
|
1368
|
+
var b = _z.value;
|
|
438
1369
|
b.hidden = sizes.indexOf(b.getAttribute("data-vg-set-size")) === -1;
|
|
439
1370
|
}
|
|
440
1371
|
}
|
|
441
|
-
catch (
|
|
1372
|
+
catch (e_33_1) { e_33 = { error: e_33_1 }; }
|
|
442
1373
|
finally {
|
|
443
1374
|
try {
|
|
444
|
-
if (
|
|
1375
|
+
if (_z && !_z.done && (_w = _y.return)) _w.call(_y);
|
|
445
1376
|
}
|
|
446
|
-
finally { if (
|
|
1377
|
+
finally { if (e_33) throw e_33.error; }
|
|
447
1378
|
}
|
|
448
1379
|
}
|
|
449
1380
|
var shown = shownIn(card2);
|
|
@@ -451,28 +1382,28 @@ var VisualCIGallery = (function () {
|
|
|
451
1382
|
var tall = Number(shown == null ? void 0 : shown.getAttribute("height")) / Number(shown == null ? void 0 : shown.getAttribute("width"));
|
|
452
1383
|
var whole = shown instanceof HTMLImageElement && (card2.getAttribute("data-vg-fit") === "contain" || tall <= (size() === "phone" ? 2.4 : 0.8));
|
|
453
1384
|
try {
|
|
454
|
-
for (var
|
|
455
|
-
var el2 =
|
|
1385
|
+
for (var _0 = __values([box, view]), _1 = _0.next(); !_1.done; _1 = _0.next()) {
|
|
1386
|
+
var el2 = _1.value;
|
|
456
1387
|
if (whole)
|
|
457
1388
|
el2.setAttribute("data-vg-fit", "");
|
|
458
1389
|
else
|
|
459
1390
|
el2.removeAttribute("data-vg-fit");
|
|
460
1391
|
}
|
|
461
1392
|
}
|
|
462
|
-
catch (
|
|
1393
|
+
catch (e_34_1) { e_34 = { error: e_34_1 }; }
|
|
463
1394
|
finally {
|
|
464
1395
|
try {
|
|
465
|
-
if (
|
|
1396
|
+
if (_1 && !_1.done && (_x = _0.return)) _x.call(_0);
|
|
466
1397
|
}
|
|
467
|
-
finally { if (
|
|
1398
|
+
finally { if (e_34) throw e_34.error; }
|
|
468
1399
|
}
|
|
469
1400
|
view.replaceChildren();
|
|
470
1401
|
if (shown instanceof HTMLImageElement) {
|
|
471
1402
|
var big_1 = document.createElement("img");
|
|
472
|
-
var src = (_c = shown.getAttribute("src")) != null ? _c : "";
|
|
1403
|
+
var src = (_d = (_c = shown.getAttribute("data-src-full")) != null ? _c : shown.getAttribute("src")) != null ? _d : "";
|
|
473
1404
|
big_1.alt = shown.alt;
|
|
474
|
-
big_1.setAttribute("width", (
|
|
475
|
-
big_1.setAttribute("height", (
|
|
1405
|
+
big_1.setAttribute("width", (_e = shown.getAttribute("width")) != null ? _e : "");
|
|
1406
|
+
big_1.setAttribute("height", (_f = shown.getAttribute("height")) != null ? _f : "");
|
|
476
1407
|
big_1.decoding = "async";
|
|
477
1408
|
var x2 = shown.getAttribute("data-src-2x");
|
|
478
1409
|
if (x2) {
|
|
@@ -486,6 +1417,12 @@ var VisualCIGallery = (function () {
|
|
|
486
1417
|
view.append(shown.cloneNode(true));
|
|
487
1418
|
}
|
|
488
1419
|
view.scrollTop = 0;
|
|
1420
|
+
if (preloader && !light()) {
|
|
1421
|
+
var list = cards();
|
|
1422
|
+
var i = list.indexOf(card2);
|
|
1423
|
+
if (i !== -1)
|
|
1424
|
+
preloader.jump(neighbours(list.map(planCard), i, theme(), hiDpi()).filter(function (n) { return n.url !== ""; }), false);
|
|
1425
|
+
}
|
|
489
1426
|
}
|
|
490
1427
|
function open(card2) {
|
|
491
1428
|
var sizes = sizesOf(card2);
|
|
@@ -534,6 +1471,105 @@ var VisualCIGallery = (function () {
|
|
|
534
1471
|
if (next)
|
|
535
1472
|
next.disabled = track.scrollLeft + track.clientWidth >= track.scrollWidth - 1;
|
|
536
1473
|
}
|
|
1474
|
+
var caps = preloadCaps(root, options.preload);
|
|
1475
|
+
var preloader = null;
|
|
1476
|
+
var hiDpi = function () { return (typeof devicePixelRatio === "number" ? devicePixelRatio : 1) > 1; };
|
|
1477
|
+
var num = function (img, name) {
|
|
1478
|
+
var v = img.getAttribute(name);
|
|
1479
|
+
return v !== null && /^\d+$/.test(v) ? Number(v) : null;
|
|
1480
|
+
};
|
|
1481
|
+
function planImage(img) {
|
|
1482
|
+
var _a2, _b2, _c, _d;
|
|
1483
|
+
var width = Number(img.getAttribute("width")) || 1;
|
|
1484
|
+
var height = Number(img.getAttribute("height")) || 1;
|
|
1485
|
+
var behind = img.getAttribute("data-src-full");
|
|
1486
|
+
var x2 = img.getAttribute("data-src-2x");
|
|
1487
|
+
var use2x = hiDpi() && x2 !== null;
|
|
1488
|
+
var tw = Math.min(width, 640);
|
|
1489
|
+
return {
|
|
1490
|
+
url: (_a2 = img.getAttribute("src")) != null ? _a2 : "",
|
|
1491
|
+
full: use2x ? x2 : behind,
|
|
1492
|
+
width: width,
|
|
1493
|
+
height: height,
|
|
1494
|
+
bytes: (_b2 = num(img, "data-vg-bytes")) != null ? _b2 : behind ? estimateBytes(tw, Math.round(height * tw / width)) : estimateBytes(width, height),
|
|
1495
|
+
fullBytes: use2x ? (_c = num(img, "data-vg-2x-bytes")) != null ? _c : estimateBytes(width * 2, height * 2) : (_d = num(img, "data-vg-full-bytes")) != null ? _d : estimateBytes(width, height)
|
|
1496
|
+
};
|
|
1497
|
+
}
|
|
1498
|
+
var planCardAt = function (card2, sz) {
|
|
1499
|
+
var imgs = toArray(card2.querySelectorAll("img.vg-img[data-vg-size=\"".concat(sz, "\"]")));
|
|
1500
|
+
var light2 = imgs.find(function (i) { return listOf(i.getAttribute("data-vg-theme")).indexOf("light") !== -1; });
|
|
1501
|
+
var dark = imgs.find(function (i) { return listOf(i.getAttribute("data-vg-theme")).indexOf("dark") !== -1; });
|
|
1502
|
+
return light2 && dark ? { light: planImage(light2), dark: planImage(dark) } : null;
|
|
1503
|
+
};
|
|
1504
|
+
var planCard = function (card2) {
|
|
1505
|
+
var _a2;
|
|
1506
|
+
return (_a2 = planCardAt(card2, size())) != null ? _a2 : { light: blank, dark: blank };
|
|
1507
|
+
};
|
|
1508
|
+
var blank = { url: "", full: null, width: 1, height: 1, bytes: 0, fullBytes: 0 };
|
|
1509
|
+
function planTabs() {
|
|
1510
|
+
var panels = tabs.length ? tabs.map(panelOf) : all(".vg-panel");
|
|
1511
|
+
var shown = panel();
|
|
1512
|
+
var current2 = Math.max(0, panels.indexOf(shown));
|
|
1513
|
+
var sizeOf = function (p) {
|
|
1514
|
+
var sizes = sizesOf(p);
|
|
1515
|
+
return sizes.length === 0 || sizes.indexOf(chosen) !== -1 ? chosen : sizes[0];
|
|
1516
|
+
};
|
|
1517
|
+
var shownSize = size();
|
|
1518
|
+
var fold = 0;
|
|
1519
|
+
var tabsOut = panels.map(function (p, i) {
|
|
1520
|
+
var sz = i === current2 ? shownSize : sizeOf(p);
|
|
1521
|
+
var els = p ? toArray(p.querySelectorAll(".vg-card")).filter(function (c) { return sizesOf(c).indexOf(sz) !== -1; }) : [];
|
|
1522
|
+
var pairs = els.map(function (el2) { return ({ el: el2, card: planCardAt(el2, sz) }); }).filter(function (x) { return x.card !== null; });
|
|
1523
|
+
if (i === current2) {
|
|
1524
|
+
fold = pairs.filter(function (_w) {
|
|
1525
|
+
var el2 = _w.el;
|
|
1526
|
+
var r = el2.getBoundingClientRect();
|
|
1527
|
+
return r.bottom > 0 && r.top < innerHeight && r.right > 0 && r.left < innerWidth;
|
|
1528
|
+
}).length;
|
|
1529
|
+
}
|
|
1530
|
+
return { sz: sz, cards: pairs.map(function (x) { return x.card; }) };
|
|
1531
|
+
});
|
|
1532
|
+
var out = tabsOut.map(function (t, i) {
|
|
1533
|
+
var f = i === current2 ? fold : t.sz === shownSize ? fold : t.sz === "phone" ? fold * 2 : Math.ceil(fold / 2);
|
|
1534
|
+
return { cards: t.cards, fold: Math.min(f, t.cards.length) };
|
|
1535
|
+
});
|
|
1536
|
+
return { tabs: out, current: current2 };
|
|
1537
|
+
}
|
|
1538
|
+
var light = function () { return lowData() || !!(preloader == null ? void 0 : preloader.slow); };
|
|
1539
|
+
function replan() {
|
|
1540
|
+
if (!preloader || !caps)
|
|
1541
|
+
return;
|
|
1542
|
+
var t = planTabs();
|
|
1543
|
+
preloader.setPlan(plan({
|
|
1544
|
+
tabs: t.tabs,
|
|
1545
|
+
current: t.current,
|
|
1546
|
+
theme: theme(),
|
|
1547
|
+
caps: caps,
|
|
1548
|
+
mode: light() ? "light" : "full",
|
|
1549
|
+
hiDpi: hiDpi(),
|
|
1550
|
+
done: preloader.loaded(),
|
|
1551
|
+
spent: preloader.spent
|
|
1552
|
+
}));
|
|
1553
|
+
}
|
|
1554
|
+
var onIntent = function (e) {
|
|
1555
|
+
var _a2, _b2;
|
|
1556
|
+
var tab = (_b2 = (_a2 = e.target).closest) == null ? void 0 : _b2.call(_a2, '[role="tab"]');
|
|
1557
|
+
if (!preloader || light() || !tab || !root.contains(tab) || tab.getAttribute("aria-selected") === "true")
|
|
1558
|
+
return;
|
|
1559
|
+
var t = planTabs();
|
|
1560
|
+
var i = tabs.indexOf(tab);
|
|
1561
|
+
if (i !== -1 && t.tabs[i])
|
|
1562
|
+
preloader.hint(tabItems(t.tabs[i], theme(), true));
|
|
1563
|
+
};
|
|
1564
|
+
var destroyed = false;
|
|
1565
|
+
var env = (_a = options.env) != null ? _a : browserEnv();
|
|
1566
|
+
var start = function () {
|
|
1567
|
+
if (destroyed || !caps || preloader)
|
|
1568
|
+
return;
|
|
1569
|
+
preloader = new Preloader(env, caps, function () { return replan(); });
|
|
1570
|
+
replan();
|
|
1571
|
+
};
|
|
1572
|
+
var onLoad = function () { return env.idle(start); };
|
|
537
1573
|
var onClick = function (e) {
|
|
538
1574
|
var target = e.target;
|
|
539
1575
|
if (target === box)
|
|
@@ -601,27 +1637,35 @@ var VisualCIGallery = (function () {
|
|
|
601
1637
|
if (followsPage) {
|
|
602
1638
|
observer = new MutationObserver(onScheme);
|
|
603
1639
|
observer.observe(document.documentElement, { attributes: true, attributeFilter: ["data-theme"] });
|
|
604
|
-
(
|
|
1640
|
+
(_b = scheme.addEventListener) == null ? void 0 : _b.call(scheme, "change", onScheme);
|
|
605
1641
|
}
|
|
606
1642
|
var resize = track && typeof ResizeObserver === "function" ? new ResizeObserver(edges) : null;
|
|
607
1643
|
if (track && resize)
|
|
608
1644
|
resize.observe(track);
|
|
609
1645
|
root.addEventListener("click", onClick);
|
|
1646
|
+
if (caps) {
|
|
1647
|
+
root.addEventListener("pointerover", onIntent);
|
|
1648
|
+
root.addEventListener("focusin", onIntent);
|
|
1649
|
+
if (document.readyState === "complete")
|
|
1650
|
+
onLoad();
|
|
1651
|
+
else
|
|
1652
|
+
addEventListener("load", onLoad, { once: true });
|
|
1653
|
+
}
|
|
610
1654
|
root.addEventListener("keydown", onKey);
|
|
611
1655
|
box.addEventListener("close", onClose);
|
|
612
1656
|
track == null ? void 0 : track.addEventListener("scroll", edges, { passive: true });
|
|
613
1657
|
try {
|
|
614
|
-
for (var
|
|
615
|
-
var img =
|
|
1658
|
+
for (var _x = __values(all("img.vg-img")), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
1659
|
+
var img = _y.value;
|
|
616
1660
|
watch(img);
|
|
617
1661
|
}
|
|
618
1662
|
}
|
|
619
|
-
catch (
|
|
1663
|
+
catch (e_29_1) { e_29 = { error: e_29_1 }; }
|
|
620
1664
|
finally {
|
|
621
1665
|
try {
|
|
622
|
-
if (
|
|
1666
|
+
if (_y && !_y.done && (_w = _x.return)) _w.call(_x);
|
|
623
1667
|
}
|
|
624
|
-
finally { if (
|
|
1668
|
+
finally { if (e_29) throw e_29.error; }
|
|
625
1669
|
}
|
|
626
1670
|
set("theme", pageTheme());
|
|
627
1671
|
fit();
|
|
@@ -634,7 +1678,7 @@ var VisualCIGallery = (function () {
|
|
|
634
1678
|
fit();
|
|
635
1679
|
},
|
|
636
1680
|
open: function (key) {
|
|
637
|
-
var
|
|
1681
|
+
var e_35, _w;
|
|
638
1682
|
try {
|
|
639
1683
|
for (var tabs_2 = __values(tabs), tabs_2_1 = tabs_2.next(); !tabs_2_1.done; tabs_2_1 = tabs_2.next()) {
|
|
640
1684
|
var t = tabs_2_1.value;
|
|
@@ -643,12 +1687,12 @@ var VisualCIGallery = (function () {
|
|
|
643
1687
|
select(t);
|
|
644
1688
|
}
|
|
645
1689
|
}
|
|
646
|
-
catch (
|
|
1690
|
+
catch (e_35_1) { e_35 = { error: e_35_1 }; }
|
|
647
1691
|
finally {
|
|
648
1692
|
try {
|
|
649
|
-
if (tabs_2_1 && !tabs_2_1.done && (
|
|
1693
|
+
if (tabs_2_1 && !tabs_2_1.done && (_w = tabs_2.return)) _w.call(tabs_2);
|
|
650
1694
|
}
|
|
651
|
-
finally { if (
|
|
1695
|
+
finally { if (e_35) throw e_35.error; }
|
|
652
1696
|
}
|
|
653
1697
|
var shownPanel = panel();
|
|
654
1698
|
var card2 = shownPanel ? cardOf(key, shownPanel) : null;
|
|
@@ -661,6 +1705,12 @@ var VisualCIGallery = (function () {
|
|
|
661
1705
|
var _a2;
|
|
662
1706
|
unlock == null ? void 0 : unlock();
|
|
663
1707
|
root.removeEventListener("click", onClick);
|
|
1708
|
+
root.removeEventListener("pointerover", onIntent);
|
|
1709
|
+
root.removeEventListener("focusin", onIntent);
|
|
1710
|
+
removeEventListener("load", onLoad);
|
|
1711
|
+
destroyed = true;
|
|
1712
|
+
preloader == null ? void 0 : preloader.stop();
|
|
1713
|
+
preloader = null;
|
|
664
1714
|
root.removeEventListener("keydown", onKey);
|
|
665
1715
|
box.removeEventListener("close", onClose);
|
|
666
1716
|
track == null ? void 0 : track.removeEventListener("scroll", edges);
|
|
@@ -673,289 +1723,6 @@ var VisualCIGallery = (function () {
|
|
|
673
1723
|
hydrated.set(root, gallery);
|
|
674
1724
|
return gallery;
|
|
675
1725
|
}
|
|
676
|
-
// src/model.ts
|
|
677
|
-
var DEFAULT_TITLE = "Screenshots";
|
|
678
|
-
var SIZES = ["desktop", "phone"];
|
|
679
|
-
var THEMES = ["light", "dark"];
|
|
680
|
-
var EXTENSION = /\.(?:[pP][nN][gG]|[jJ][pP][eE]?[gG]|[wW][eE][bB][pP])$/;
|
|
681
|
-
var WIDTH_THEME = /^([0-9]+)-(light|dark)(-2x)?$/;
|
|
682
|
-
var SCREEN_THEME = /^([\s\S]+?)-(light|dark)(?:-([0-9]+))?(-2x)?$/;
|
|
683
|
-
var SEE_ALL_TEXT = "See all screenshots";
|
|
684
|
-
function parseShot(name, width, height, size) {
|
|
685
|
-
var parts = name.replace(EXTENSION, "").split("/");
|
|
686
|
-
var last = parts.pop();
|
|
687
|
-
var folder = parts.join("/");
|
|
688
|
-
var sized = function (w) { return w !== void 0 ? Number(w) < 768 ? "phone" : "desktop" : size != null ? size : height > width ? "phone" : "desktop"; };
|
|
689
|
-
var css = function (w) { return w !== void 0 ? Number(w) : null; };
|
|
690
|
-
var m = WIDTH_THEME.exec(last);
|
|
691
|
-
if (m && folder) {
|
|
692
|
-
return { key: folder, theme: m[2], size: sized(m[1]), x2: !!m[3], cssWidth: css(m[1]) };
|
|
693
|
-
}
|
|
694
|
-
m = SCREEN_THEME.exec(last);
|
|
695
|
-
if (m) {
|
|
696
|
-
var key = folder ? "".concat(folder, "/").concat(m[1]) : m[1];
|
|
697
|
-
return { key: key, theme: m[2], size: sized(m[3]), x2: !!m[4], cssWidth: css(m[3]) };
|
|
698
|
-
}
|
|
699
|
-
return { key: folder ? "".concat(folder, "/").concat(last) : last, theme: null, size: sized(void 0), x2: false, cssWidth: null };
|
|
700
|
-
}
|
|
701
|
-
function humanize(segments) {
|
|
702
|
-
var text = segments.map(function (s) { return s.replace(/[-_]+/g, " ").replace(/^ +| +$/g, ""); }).join(", ");
|
|
703
|
-
var first = text.codePointAt(0);
|
|
704
|
-
if (first === void 0)
|
|
705
|
-
return text;
|
|
706
|
-
var head = String.fromCodePoint(first);
|
|
707
|
-
return head.toUpperCase() + text.slice(head.length);
|
|
708
|
-
}
|
|
709
|
-
function slugify(name) {
|
|
710
|
-
return name.replace(/[A-Z]/g, function (c) { return c.toLowerCase(); }).replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") || "group";
|
|
711
|
-
}
|
|
712
|
-
function commonFolder(keys) {
|
|
713
|
-
var e_14, _p;
|
|
714
|
-
var folders = keys.map(function (k) { return k.split("/").slice(0, -1); });
|
|
715
|
-
if (folders.length === 0)
|
|
716
|
-
return [];
|
|
717
|
-
var common = folders[0];
|
|
718
|
-
try {
|
|
719
|
-
for (var _q = __values(folders.slice(1)), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
720
|
-
var f = _r.value;
|
|
721
|
-
var i = 0;
|
|
722
|
-
while (i < common.length && i < f.length && common[i] === f[i])
|
|
723
|
-
i++;
|
|
724
|
-
common = common.slice(0, i);
|
|
725
|
-
}
|
|
726
|
-
}
|
|
727
|
-
catch (e_14_1) { e_14 = { error: e_14_1 }; }
|
|
728
|
-
finally {
|
|
729
|
-
try {
|
|
730
|
-
if (_r && !_r.done && (_p = _q.return)) _p.call(_q);
|
|
731
|
-
}
|
|
732
|
-
finally { if (e_14) throw e_14.error; }
|
|
733
|
-
}
|
|
734
|
-
return common;
|
|
735
|
-
}
|
|
736
|
-
function rankBy(order) {
|
|
737
|
-
var list = order != null ? order : [];
|
|
738
|
-
return function (key) {
|
|
739
|
-
var i = list.indexOf(key);
|
|
740
|
-
return i === -1 ? list.length : i;
|
|
741
|
-
};
|
|
742
|
-
}
|
|
743
|
-
function compare(a, b) {
|
|
744
|
-
var x = Array.from(a, function (c) { return c.codePointAt(0); });
|
|
745
|
-
var y = Array.from(b, function (c) { return c.codePointAt(0); });
|
|
746
|
-
for (var i = 0; i < Math.min(x.length, y.length); i++)
|
|
747
|
-
if (x[i] !== y[i])
|
|
748
|
-
return x[i] - y[i];
|
|
749
|
-
return x.length - y.length;
|
|
750
|
-
}
|
|
751
|
-
var ABSOLUTE = /^[hH][tT][tT][pP][sS]?:\/\/[^\x00-\x20\x7f]+$/;
|
|
752
|
-
function safeHref(value) {
|
|
753
|
-
return ABSOLUTE.test(value) || value !== "" && !/[\x00-\x20\x7f]/.test(value) && !/^[A-Za-z][A-Za-z0-9+.-]*:/.test(value);
|
|
754
|
-
}
|
|
755
|
-
var ID = /^[A-Za-z][A-Za-z0-9_-]*$/;
|
|
756
|
-
function fail(message) {
|
|
757
|
-
throw new Error(message);
|
|
758
|
-
}
|
|
759
|
-
var isObject = function (v) { return typeof v === "object" && v !== null && !Array.isArray(v); };
|
|
760
|
-
var MAX_SIZE = 1e6;
|
|
761
|
-
var isSize = function (v) { return typeof v === "number" && Number.isInteger(v) && v > 0 && v <= MAX_SIZE; };
|
|
762
|
-
function opt(value, check, what) {
|
|
763
|
-
if (value === null || value === void 0)
|
|
764
|
-
return void 0;
|
|
765
|
-
if (!check(value))
|
|
766
|
-
fail("gallery option ".concat(what, " is invalid"));
|
|
767
|
-
return value;
|
|
768
|
-
}
|
|
769
|
-
var isString = function (v) { return typeof v === "string"; };
|
|
770
|
-
var isStrings = function (v) { return Array.isArray(v) && v.every(isString); };
|
|
771
|
-
var isTexts = function (keys) { return function (v) { return isObject(v) && Object.values(v).every(function (entry) { return isObject(entry) && Object.entries(entry).every(function (_p) {
|
|
772
|
-
var _q = __read(_p, 2), k = _q[0], x = _q[1];
|
|
773
|
-
return keys.includes(k) && (x === null || isString(x));
|
|
774
|
-
}); }); }; };
|
|
775
|
-
function checkManifest(manifest) {
|
|
776
|
-
if (!isObject(manifest) || !Array.isArray(manifest.groups))
|
|
777
|
-
fail("not a gallery manifest: it has no groups");
|
|
778
|
-
manifest.groups.forEach(function (g, i) {
|
|
779
|
-
if (!isObject(g) || typeof g.name !== "string" || g.name === "")
|
|
780
|
-
fail("gallery manifest group ".concat(i, " has no name"));
|
|
781
|
-
if (g.title !== void 0 && g.title !== null && typeof g.title !== "string")
|
|
782
|
-
fail("gallery manifest group ".concat(g.name, ": its title isn't a string"));
|
|
783
|
-
if (!Array.isArray(g.items))
|
|
784
|
-
fail("gallery manifest group ".concat(g.name, " has no items"));
|
|
785
|
-
g.items.forEach(function (item, j) {
|
|
786
|
-
var where = "gallery manifest group ".concat(g.name, ", item ").concat(j);
|
|
787
|
-
if (!isObject(item) || typeof item.name !== "string" || item.name === "")
|
|
788
|
-
fail("".concat(where, " has no name"));
|
|
789
|
-
if (typeof item.url !== "string" || !ABSOLUTE.test(item.url))
|
|
790
|
-
fail("".concat(where, " (").concat(item.name, "): its url isn't an http(s) URL"));
|
|
791
|
-
if (!isSize(item.width) || !isSize(item.height))
|
|
792
|
-
fail("".concat(where, " (").concat(item.name, "): its width and height aren't whole numbers from 1 to 1000000"));
|
|
793
|
-
});
|
|
794
|
-
});
|
|
795
|
-
}
|
|
796
|
-
function buildModel(manifest, options) {
|
|
797
|
-
var e_15, _p;
|
|
798
|
-
if (options === void 0) { options = {}; }
|
|
799
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
800
|
-
checkManifest(manifest);
|
|
801
|
-
if (!isObject(options))
|
|
802
|
-
fail("gallery options must be an object");
|
|
803
|
-
var o = options;
|
|
804
|
-
var level = (_a = opt(o.headingLevel, function (v) { return Number.isInteger(v); }, "headingLevel")) != null ? _a : 2;
|
|
805
|
-
var headingLevel = Math.min(Math.max(level, 1), 4);
|
|
806
|
-
var title = o.title === void 0 ? DEFAULT_TITLE : (_b = opt(o.title, isString, "title")) != null ? _b : null;
|
|
807
|
-
var id = (_c = opt(o.id, function (v) { return isString(v) && ID.test(v); }, "id")) != null ? _c : "vg";
|
|
808
|
-
var screensOpt = (_d = opt(o.screens, isTexts(["title", "caption"]), "screens")) != null ? _d : {};
|
|
809
|
-
var groupsOpt = (_e = opt(o.groups, function (v) { return isObject(v) && Object.values(v).every(function (entry) { return isObject(entry) && Object.entries(entry).every(function (_p) {
|
|
810
|
-
var _q = __read(_p, 2), k = _q[0], x = _q[1];
|
|
811
|
-
return k === "title" && (x === null || isString(x)) || k === "size" && (x === null || SIZES.includes(x)) || k === "fit" && (x === null || x === "cover" || x === "contain");
|
|
812
|
-
}); }); }, "groups")) != null ? _e : {};
|
|
813
|
-
var order = opt(o.order, isStrings, "order");
|
|
814
|
-
var groupOrder = opt(o.groupOrder, isStrings, "groupOrder");
|
|
815
|
-
var credit = (_f = opt(o.credit, function (v) { return typeof v === "boolean"; }, "credit")) != null ? _f : true;
|
|
816
|
-
var themeSwitchOpt = (_g = opt(o.themeSwitch, function (v) { return typeof v === "boolean"; }, "themeSwitch")) != null ? _g : true;
|
|
817
|
-
var layout = (_h = opt(o.layout, function (v) { return v === "grid" || v === "strip"; }, "layout")) != null ? _h : "grid";
|
|
818
|
-
var seeAllOpt = opt(o.seeAll, function (v) { return isObject(v) && isString(v.href) && safeHref(v.href) && (v.text === void 0 || v.text === null || isString(v.text)); }, "seeAll");
|
|
819
|
-
var slugs = /* @__PURE__ */ new Set();
|
|
820
|
-
var groups = [];
|
|
821
|
-
var _loop_3 = function (g) {
|
|
822
|
-
var e_16, _s, e_17, _t, e_18, _u, e_19, _v;
|
|
823
|
-
var groupSet = Object.prototype.hasOwnProperty.call(groupsOpt, g.name) ? groupsOpt[g.name] : void 0;
|
|
824
|
-
var screens = /* @__PURE__ */ new Map();
|
|
825
|
-
try {
|
|
826
|
-
for (var _w = (e_16 = void 0, __values(g.items)), _x = _w.next(); !_x.done; _x = _w.next()) {
|
|
827
|
-
var item = _x.value;
|
|
828
|
-
var shot = parseShot(item.name, item.width, item.height, (_i = groupSet == null ? void 0 : groupSet.size) != null ? _i : void 0);
|
|
829
|
-
var variants = (_j = screens.get(shot.key)) != null ? _j : /* @__PURE__ */ new Map();
|
|
830
|
-
screens.set(shot.key, variants);
|
|
831
|
-
try {
|
|
832
|
-
for (var _y = (e_17 = void 0, __values(shot.theme ? [shot.theme] : THEMES)), _z = _y.next(); !_z.done; _z = _y.next()) {
|
|
833
|
-
var theme = _z.value;
|
|
834
|
-
var vid = "".concat(shot.size, "-").concat(theme);
|
|
835
|
-
var v = (_k = variants.get(vid)) != null ? _k : { size: shot.size, theme: theme, url: "", url2x: null, width: 0, height: 0 };
|
|
836
|
-
if (shot.x2) {
|
|
837
|
-
if (v.url2x === null)
|
|
838
|
-
v.url2x = item.url;
|
|
839
|
-
}
|
|
840
|
-
else if (v.url === "") {
|
|
841
|
-
var scaled = shot.cssWidth !== null && item.width > shot.cssWidth;
|
|
842
|
-
var width = scaled ? shot.cssWidth : item.width;
|
|
843
|
-
var height = scaled ? Math.floor((2 * item.height * shot.cssWidth + item.width) / (2 * item.width)) : item.height;
|
|
844
|
-
Object.assign(v, { url: item.url, width: width, height: height });
|
|
845
|
-
}
|
|
846
|
-
variants.set(vid, v);
|
|
847
|
-
}
|
|
848
|
-
}
|
|
849
|
-
catch (e_17_1) { e_17 = { error: e_17_1 }; }
|
|
850
|
-
finally {
|
|
851
|
-
try {
|
|
852
|
-
if (_z && !_z.done && (_t = _y.return)) _t.call(_y);
|
|
853
|
-
}
|
|
854
|
-
finally { if (e_17) throw e_17.error; }
|
|
855
|
-
}
|
|
856
|
-
}
|
|
857
|
-
}
|
|
858
|
-
catch (e_16_1) { e_16 = { error: e_16_1 }; }
|
|
859
|
-
finally {
|
|
860
|
-
try {
|
|
861
|
-
if (_x && !_x.done && (_s = _w.return)) _s.call(_w);
|
|
862
|
-
}
|
|
863
|
-
finally { if (e_16) throw e_16.error; }
|
|
864
|
-
}
|
|
865
|
-
var kept = __spreadArray([], __read(screens), false).map(function (_p) {
|
|
866
|
-
var _q = __read(_p, 2), key = _q[0], variants = _q[1];
|
|
867
|
-
return ({
|
|
868
|
-
key: key,
|
|
869
|
-
variants: __spreadArray([], __read(variants.values()), false).filter(function (v) { return v.url !== ""; }).sort(function (a, b) { return SIZES.indexOf(a.size) - SIZES.indexOf(b.size) || THEMES.indexOf(a.theme) - THEMES.indexOf(b.theme); })
|
|
870
|
-
});
|
|
871
|
-
}).filter(function (sc) { return sc.variants.length > 0; });
|
|
872
|
-
try {
|
|
873
|
-
for (var kept_1 = (e_18 = void 0, __values(kept)), kept_1_1 = kept_1.next(); !kept_1_1.done; kept_1_1 = kept_1.next()) {
|
|
874
|
-
var sc = kept_1_1.value;
|
|
875
|
-
var _loop_4 = function (v) {
|
|
876
|
-
if (!sc.variants.some(function (o2) { return o2.size === v.size && o2.theme !== v.theme; })) {
|
|
877
|
-
fail("gallery screen ".concat(sc.key, " in group ").concat(g.name, " has a ").concat(v.theme, " ").concat(v.size, " screenshot but no ").concat(v.theme === "light" ? "dark" : "light", " one"));
|
|
878
|
-
}
|
|
879
|
-
};
|
|
880
|
-
try {
|
|
881
|
-
for (var _0 = (e_19 = void 0, __values(sc.variants)), _1 = _0.next(); !_1.done; _1 = _0.next()) {
|
|
882
|
-
var v = _1.value;
|
|
883
|
-
_loop_4(v);
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
catch (e_19_1) { e_19 = { error: e_19_1 }; }
|
|
887
|
-
finally {
|
|
888
|
-
try {
|
|
889
|
-
if (_1 && !_1.done && (_v = _0.return)) _v.call(_0);
|
|
890
|
-
}
|
|
891
|
-
finally { if (e_19) throw e_19.error; }
|
|
892
|
-
}
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
catch (e_18_1) { e_18 = { error: e_18_1 }; }
|
|
896
|
-
finally {
|
|
897
|
-
try {
|
|
898
|
-
if (kept_1_1 && !kept_1_1.done && (_u = kept_1.return)) _u.call(kept_1);
|
|
899
|
-
}
|
|
900
|
-
finally { if (e_18) throw e_18.error; }
|
|
901
|
-
}
|
|
902
|
-
if (kept.length === 0)
|
|
903
|
-
return "continue";
|
|
904
|
-
var prefix = commonFolder(kept.map(function (sc) { return sc.key; })).length;
|
|
905
|
-
var rank = rankBy(order);
|
|
906
|
-
var list = kept.map(function (_p) {
|
|
907
|
-
var key = _p.key, variants = _p.variants;
|
|
908
|
-
var _a2, _b2;
|
|
909
|
-
var set = Object.prototype.hasOwnProperty.call(screensOpt, key) ? screensOpt[key] : void 0;
|
|
910
|
-
return {
|
|
911
|
-
key: key,
|
|
912
|
-
title: (_a2 = set == null ? void 0 : set.title) != null ? _a2 : humanize(key.split("/").slice(prefix)),
|
|
913
|
-
caption: (_b2 = set == null ? void 0 : set.caption) != null ? _b2 : null,
|
|
914
|
-
variants: variants
|
|
915
|
-
};
|
|
916
|
-
}).sort(function (a, b) { return rank(a.key) - rank(b.key) || compare(a.key, b.key); });
|
|
917
|
-
var slug = slugify(g.name);
|
|
918
|
-
for (var n = 2; slugs.has(slug); n++)
|
|
919
|
-
slug = "".concat(slugify(g.name), "-").concat(n);
|
|
920
|
-
slugs.add(slug);
|
|
921
|
-
groups.push({
|
|
922
|
-
name: g.name,
|
|
923
|
-
title: (_m = (_l = groupSet == null ? void 0 : groupSet.title) != null ? _l : g.title) != null ? _m : g.name,
|
|
924
|
-
slug: slug,
|
|
925
|
-
fit: (_n = groupSet == null ? void 0 : groupSet.fit) != null ? _n : "cover",
|
|
926
|
-
sizes: SIZES.filter(function (sz) { return list.some(function (sc) { return sc.variants.some(function (v) { return v.size === sz; }); }); }),
|
|
927
|
-
screens: list
|
|
928
|
-
});
|
|
929
|
-
};
|
|
930
|
-
try {
|
|
931
|
-
for (var _q = __values(manifest.groups), _r = _q.next(); !_r.done; _r = _q.next()) {
|
|
932
|
-
var g = _r.value;
|
|
933
|
-
_loop_3(g);
|
|
934
|
-
}
|
|
935
|
-
}
|
|
936
|
-
catch (e_15_1) { e_15 = { error: e_15_1 }; }
|
|
937
|
-
finally {
|
|
938
|
-
try {
|
|
939
|
-
if (_r && !_r.done && (_p = _q.return)) _p.call(_q);
|
|
940
|
-
}
|
|
941
|
-
finally { if (e_15) throw e_15.error; }
|
|
942
|
-
}
|
|
943
|
-
if (groups.length === 0)
|
|
944
|
-
fail("the gallery manifest has no screenshots to show");
|
|
945
|
-
var groupRank = rankBy(groupOrder);
|
|
946
|
-
groups.sort(function (a, b) { return groupRank(a.name) - groupRank(b.name); });
|
|
947
|
-
return {
|
|
948
|
-
layout: layout,
|
|
949
|
-
themeSwitch: layout === "grid" && themeSwitchOpt,
|
|
950
|
-
seeAll: seeAllOpt ? { href: seeAllOpt.href, text: (_o = seeAllOpt.text) != null ? _o : SEE_ALL_TEXT } : null,
|
|
951
|
-
title: title,
|
|
952
|
-
label: title != null ? title : DEFAULT_TITLE,
|
|
953
|
-
headingLevel: headingLevel,
|
|
954
|
-
id: id,
|
|
955
|
-
credit: credit,
|
|
956
|
-
groups: groups
|
|
957
|
-
};
|
|
958
|
-
}
|
|
959
1726
|
// src/load.ts
|
|
960
1727
|
function timeout(ms) {
|
|
961
1728
|
if (typeof AbortSignal.timeout === "function")
|
|
@@ -966,50 +1733,50 @@ var VisualCIGallery = (function () {
|
|
|
966
1733
|
}
|
|
967
1734
|
function load(options) {
|
|
968
1735
|
return __awaiter(this, void 0, void 0, function () {
|
|
969
|
-
var _a, _b, _c, get, attempts, last, manifest,
|
|
970
|
-
return __generator(this, function (
|
|
971
|
-
switch (
|
|
1736
|
+
var _a, _b, _c, get, attempts, last, manifest, _loop_6, attempt, state_2;
|
|
1737
|
+
return __generator(this, function (_w) {
|
|
1738
|
+
switch (_w.label) {
|
|
972
1739
|
case 0:
|
|
973
1740
|
get = (_a = options.fetch) != null ? _a : fetch;
|
|
974
1741
|
attempts = Math.max(1, (_b = options.attempts) != null ? _b : 3);
|
|
975
|
-
|
|
976
|
-
var res,
|
|
977
|
-
return __generator(this, function (
|
|
978
|
-
switch (
|
|
1742
|
+
_loop_6 = function (attempt) {
|
|
1743
|
+
var res, e_36;
|
|
1744
|
+
return __generator(this, function (_x) {
|
|
1745
|
+
switch (_x.label) {
|
|
979
1746
|
case 0:
|
|
980
|
-
|
|
1747
|
+
_x.trys.push([0, 3, , 6]);
|
|
981
1748
|
return [4 /*yield*/, get(options.manifest, { signal: timeout((_c = options.timeout) != null ? _c : 2e4) })];
|
|
982
1749
|
case 1:
|
|
983
|
-
res =
|
|
1750
|
+
res = _x.sent();
|
|
984
1751
|
if (!res.ok)
|
|
985
1752
|
throw new Error("HTTP ".concat(res.status));
|
|
986
1753
|
return [4 /*yield*/, res.json()];
|
|
987
1754
|
case 2:
|
|
988
|
-
manifest =
|
|
1755
|
+
manifest = _x.sent();
|
|
989
1756
|
return [2 /*return*/, "break"];
|
|
990
1757
|
case 3:
|
|
991
|
-
|
|
992
|
-
last =
|
|
1758
|
+
e_36 = _x.sent();
|
|
1759
|
+
last = e_36;
|
|
993
1760
|
if (!(attempt < attempts)) return [3 /*break*/, 5];
|
|
994
1761
|
return [4 /*yield*/, new Promise(function (r) { return setTimeout(r, attempt * 1e3); })];
|
|
995
1762
|
case 4:
|
|
996
|
-
|
|
997
|
-
|
|
1763
|
+
_x.sent();
|
|
1764
|
+
_x.label = 5;
|
|
998
1765
|
case 5: return [3 /*break*/, 6];
|
|
999
1766
|
case 6: return [2 /*return*/];
|
|
1000
1767
|
}
|
|
1001
1768
|
});
|
|
1002
1769
|
};
|
|
1003
1770
|
attempt = 1;
|
|
1004
|
-
|
|
1771
|
+
_w.label = 1;
|
|
1005
1772
|
case 1:
|
|
1006
1773
|
if (!(attempt <= attempts)) return [3 /*break*/, 4];
|
|
1007
|
-
return [5 /*yield**/,
|
|
1774
|
+
return [5 /*yield**/, _loop_6(attempt)];
|
|
1008
1775
|
case 2:
|
|
1009
|
-
|
|
1010
|
-
if (
|
|
1776
|
+
state_2 = _w.sent();
|
|
1777
|
+
if (state_2 === "break")
|
|
1011
1778
|
return [3 /*break*/, 4];
|
|
1012
|
-
|
|
1779
|
+
_w.label = 3;
|
|
1013
1780
|
case 3:
|
|
1014
1781
|
attempt++;
|
|
1015
1782
|
return [3 /*break*/, 1];
|
|
@@ -1031,22 +1798,22 @@ var VisualCIGallery = (function () {
|
|
|
1031
1798
|
// src/index.ts
|
|
1032
1799
|
function mount(el, options) {
|
|
1033
1800
|
return __awaiter(this, void 0, void 0, function () {
|
|
1034
|
-
var _a, model,
|
|
1035
|
-
return __generator(this, function (
|
|
1036
|
-
switch (
|
|
1801
|
+
var _a, model, e_37, p, old;
|
|
1802
|
+
return __generator(this, function (_w) {
|
|
1803
|
+
switch (_w.label) {
|
|
1037
1804
|
case 0:
|
|
1038
|
-
|
|
1805
|
+
_w.trys.push([0, 2, , 3]);
|
|
1039
1806
|
return [4 /*yield*/, load(options)];
|
|
1040
1807
|
case 1:
|
|
1041
|
-
model =
|
|
1808
|
+
model = _w.sent();
|
|
1042
1809
|
return [3 /*break*/, 3];
|
|
1043
1810
|
case 2:
|
|
1044
|
-
|
|
1811
|
+
e_37 = _w.sent();
|
|
1045
1812
|
p = document.createElement("p");
|
|
1046
1813
|
p.className = "vg-error";
|
|
1047
1814
|
p.textContent = "The screenshots couldn't be loaded.";
|
|
1048
1815
|
el.replaceChildren(p);
|
|
1049
|
-
throw
|
|
1816
|
+
throw e_37;
|
|
1050
1817
|
case 3:
|
|
1051
1818
|
old = el.querySelector("[data-vg]");
|
|
1052
1819
|
if (old)
|