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