yard 0.9.41 → 0.9.42

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.
@@ -1,640 +1,801 @@
1
- (function() {
2
- var appState = window.__yardAppState || (window.__yardAppState = {
3
- navigationListenerBound: false,
4
- navigationChangeBound: false,
5
- navResizerBound: false,
6
- searchFrameGlobalsBound: false,
7
- latestNavigationId: 0,
8
- loadingIndicatorTimer: null,
9
- navExpanderTimer: null,
10
- navExpanderToken: 0
11
- });
12
- var safeLocalStorage = {};
13
- var safeSessionStorage = {};
14
-
15
- try {
16
- safeLocalStorage = window.localStorage;
17
- } catch (error) {}
18
-
19
- try {
20
- safeSessionStorage = window.sessionStorage;
21
- } catch (error) {}
22
-
23
- function query(selector, root) {
24
- return (root || document).querySelector(selector);
25
- }
26
-
27
- function queryAll(selector, root) {
28
- return Array.prototype.slice.call(
29
- (root || document).querySelectorAll(selector)
30
- );
31
- }
32
-
33
- function isVisible(element) {
34
- if (!element) return false;
35
- return window.getComputedStyle(element).display !== "none";
36
- }
37
-
38
- function toggleDisplay(element, visible, displayValue) {
39
- if (!element) return;
40
- element.style.display = visible ? (displayValue || "") : "none";
41
- }
42
-
43
- function setMainLoading(loading) {
44
- var main = query("#main");
45
- if (!main) return;
46
- main.classList.toggle("loading", !!loading);
47
- main.setAttribute("aria-busy", loading ? "true" : "false");
48
- }
49
-
50
- function scheduleMainLoading(navigationId) {
51
- clearTimeout(appState.loadingIndicatorTimer);
52
- appState.loadingIndicatorTimer = setTimeout(function() {
53
- if (navigationId === appState.latestNavigationId) {
54
- setMainLoading(true);
55
- }
56
- appState.loadingIndicatorTimer = null;
57
- }, 50);
58
- }
59
-
60
- function cancelMainLoading() {
61
- clearTimeout(appState.loadingIndicatorTimer);
62
- appState.loadingIndicatorTimer = null;
63
- setMainLoading(false);
64
- }
65
-
66
- function firstNextMatchingSibling(element, selector) {
67
- var current = element;
68
- while (current) {
69
- current = current.nextElementSibling;
70
- if (current && current.matches(selector)) return current;
71
- }
72
- return null;
73
- }
74
-
75
- function ready(callback) {
76
- if (document.readyState === "loading") {
77
- document.addEventListener("DOMContentLoaded", callback, { once: true });
78
- } else {
79
- callback();
80
- }
81
- }
82
-
83
- function createSourceLinks() {
84
- queryAll(".method_details_list .source_code").forEach(function(sourceCode) {
85
- var toggleWrapper = document.createElement("span");
86
- var link = document.createElement("a");
87
-
88
- toggleWrapper.className = "showSource";
89
- toggleWrapper.appendChild(document.createTextNode("["));
90
- toggleWrapper.appendChild(link);
91
- toggleWrapper.appendChild(document.createTextNode("]"));
92
-
93
- link.href = "#";
94
- link.className = "toggleSource";
95
- link.textContent = "View source";
96
-
97
- link.addEventListener("click", function(event) {
98
- event.preventDefault();
99
- var expanded = isVisible(sourceCode);
100
- toggleDisplay(sourceCode, !expanded, "table");
101
- link.textContent = expanded ? "View source" : "Hide source";
102
- });
103
-
104
- sourceCode.parentNode.insertBefore(toggleWrapper, sourceCode);
105
- });
106
- }
107
-
108
- function createDefineLinks() {
109
- queryAll(".defines").forEach(function(defines) {
110
- var toggleLink = document.createElement("a");
111
- var summary = defines.parentElement.previousElementSibling;
112
-
113
- toggleLink.href = "#";
114
- toggleLink.className = "toggleDefines";
115
- toggleLink.textContent = "more...";
116
- defines.insertAdjacentText("afterend", " ");
117
- defines.insertAdjacentElement("afterend", toggleLink);
118
-
119
- toggleLink.addEventListener("click", function(event) {
120
- event.preventDefault();
121
- var expanded = toggleLink.dataset.expanded === "true";
122
-
123
- if (!expanded) {
124
- toggleLink.dataset.height = String(summary.offsetHeight);
125
- defines.style.display = "inline";
126
- summary.style.height = toggleLink.parentElement.offsetHeight + "px";
127
- toggleLink.textContent = "(less)";
128
- toggleLink.dataset.expanded = "true";
129
- } else {
130
- defines.style.display = "none";
131
- if (toggleLink.dataset.height) {
132
- summary.style.height = toggleLink.dataset.height + "px";
133
- }
134
- toggleLink.textContent = "more...";
135
- toggleLink.dataset.expanded = "false";
136
- }
137
- });
138
- });
139
- }
140
-
141
- function createFullTreeLinks() {
142
- queryAll(".inheritanceTree").forEach(function(toggleLink) {
143
- var container = toggleLink.parentElement;
144
- var tree = container.previousElementSibling;
145
-
146
- toggleLink.addEventListener("click", function(event) {
147
- event.preventDefault();
148
- var expanded = toggleLink.dataset.expanded === "true";
149
-
150
- if (!expanded) {
151
- toggleLink.dataset.height = String(tree.offsetHeight);
152
- container.classList.add("showAll");
153
- toggleLink.textContent = "(hide)";
154
- tree.style.height = container.offsetHeight + "px";
155
- toggleLink.dataset.expanded = "true";
156
- } else {
157
- container.classList.remove("showAll");
158
- if (toggleLink.dataset.height) {
159
- tree.style.height = toggleLink.dataset.height + "px";
160
- }
161
- toggleLink.textContent = "show all";
162
- toggleLink.dataset.expanded = "false";
163
- }
164
- });
165
- });
166
- }
167
-
168
- function resetSearchFrame() {
169
- var frame = query("#nav");
170
-
171
- if (frame) frame.removeAttribute("style");
172
- queryAll("#search a").forEach(function(link) {
173
- link.classList.remove("active");
174
- link.classList.remove("inactive");
175
- });
176
- window.focus();
177
- }
178
-
179
- function toggleSearchFrame(linkElement, link) {
180
- var frame = query("#nav");
181
-
182
- if (!frame) return;
183
-
184
- queryAll("#search a").forEach(function(searchLink) {
185
- searchLink.classList.remove("active");
186
- searchLink.classList.add("inactive");
187
- });
188
-
189
- if (frame.getAttribute("src") === link && isVisible(frame)) {
190
- frame.style.display = "none";
191
- queryAll("#search a").forEach(function(searchLink) {
192
- searchLink.classList.remove("active");
193
- searchLink.classList.remove("inactive");
194
- });
195
- } else {
196
- linkElement.classList.add("active");
197
- linkElement.classList.remove("inactive");
198
- if (frame.getAttribute("src") !== link) frame.setAttribute("src", link);
199
- frame.style.display = "block";
200
- }
201
- }
202
-
203
- function searchFrameButtons() {
204
- queryAll(".full_list_link").forEach(function(link) {
205
- if (link.dataset.yardSearchFrameBound === "true") return;
206
-
207
- link.addEventListener("click", function(event) {
208
- event.preventDefault();
209
- toggleSearchFrame(link, link.getAttribute("href"));
210
- });
211
-
212
- link.dataset.yardSearchFrameBound = "true";
213
- });
214
-
215
- if (appState.searchFrameGlobalsBound) return;
216
-
217
- window.addEventListener("message", function(event) {
218
- if (event.data === "navEscape") resetSearchFrame();
219
- });
220
-
221
- window.addEventListener("resize", function() {
222
- if (!isVisible(query("#search"))) resetSearchFrame();
223
- });
224
-
225
- appState.searchFrameGlobalsBound = true;
226
- }
227
-
228
- function linkSummaries() {
229
- queryAll(".summary_signature").forEach(function(signature) {
230
- signature.addEventListener("click", function(event) {
231
- if (event.target.closest("a")) return;
232
- var link = signature.querySelector("a");
233
- if (link) document.location = link.getAttribute("href");
234
- });
235
- });
236
- }
237
-
238
- function toggleSummaryCollection(toggleSelector, listSelector, cloneBuilder) {
239
- queryAll(toggleSelector).forEach(function(toggleLink) {
240
- toggleLink.addEventListener("click", function(event) {
241
- event.preventDefault();
242
- safeLocalStorage.summaryCollapsed = toggleLink.textContent;
243
-
244
- queryAll(toggleSelector).forEach(function(link) {
245
- link.textContent =
246
- link.textContent === "collapse" ? "expand" : "collapse";
247
-
248
- var container = link.parentElement.parentElement;
249
- var next = firstNextMatchingSibling(container, listSelector);
250
-
251
- if (!next) return;
252
-
253
- if (next.classList.contains("compact")) {
254
- var fullList = firstNextMatchingSibling(next, listSelector);
255
- toggleDisplay(next, !isVisible(next));
256
- toggleDisplay(fullList, !isVisible(fullList));
257
- } else {
258
- var compactList = cloneBuilder(next.cloneNode(true));
259
- next.parentNode.insertBefore(compactList, next);
260
- toggleDisplay(next, false);
261
- }
262
- });
263
- });
264
- });
265
- }
266
-
267
- function buildCompactSummary(list) {
268
- list.className = "summary compact";
269
-
270
- queryAll(".summary_desc, .note", list).forEach(function(node) {
271
- node.remove();
272
- });
273
-
274
- queryAll("a", list).forEach(function(link) {
275
- var strong = link.querySelector("strong");
276
- if (strong) link.innerHTML = strong.innerHTML;
277
- if (link.parentElement) link.parentElement.outerHTML = link.outerHTML;
278
- });
279
-
280
- return list;
281
- }
282
-
283
- function buildCompactConstants(list) {
284
- list.className = "constants compact";
285
-
286
- queryAll("dt", list).forEach(function(node) {
287
- var deprecated = !!node.querySelector(".deprecated");
288
- node.classList.add("summary_signature");
289
- node.textContent = node.textContent.split("=")[0];
290
- if (deprecated) node.classList.add("deprecated");
291
- });
292
-
293
- queryAll("pre.code", list).forEach(function(pre) {
294
- var dtElement = pre.parentElement.previousElementSibling;
295
- var tooltip = pre.textContent;
296
- if (dtElement.classList.contains("deprecated")) {
297
- tooltip = "Deprecated. " + tooltip;
298
- }
299
- dtElement.setAttribute("title", tooltip);
300
- });
301
-
302
- queryAll(".docstring, .tags, dd", list).forEach(function(node) {
303
- node.remove();
304
- });
305
-
306
- return list;
307
- }
308
-
309
- function summaryToggle() {
310
- toggleSummaryCollection(".summary_toggle", "ul.summary", buildCompactSummary);
311
-
312
- if (safeLocalStorage.summaryCollapsed === "collapse") {
313
- var toggle = query(".summary_toggle");
314
- if (toggle) toggle.click();
315
- } else {
316
- safeLocalStorage.summaryCollapsed = "expand";
317
- }
318
- }
319
-
320
- function constantSummaryToggle() {
321
- toggleSummaryCollection(
322
- ".constants_summary_toggle",
323
- "dl.constants",
324
- buildCompactConstants
325
- );
326
-
327
- if (safeLocalStorage.summaryCollapsed === "collapse") {
328
- var toggle = query(".constants_summary_toggle");
329
- if (toggle) toggle.click();
330
- } else {
331
- safeLocalStorage.summaryCollapsed = "expand";
332
- }
333
- }
334
-
335
- function generateTOC() {
336
- var fileContents = query("#filecontents");
337
- var content = query("#content");
338
-
339
- if (!fileContents || !content) return;
340
-
341
- var topLevel = document.createElement("ol");
342
- var currentList = topLevel;
343
- var currentItem;
344
- var counter = 0;
345
- var headings = ["h2", "h3", "h4", "h5", "h6"];
346
- var hasEntries = false;
347
-
348
- topLevel.className = "top";
349
-
350
- if (queryAll("#filecontents h1").length > 1) headings.unshift("h1");
351
-
352
- var selectors = headings.map(function(tagName) {
353
- return "#filecontents " + tagName;
354
- });
355
-
356
- var lastLevel = parseInt(headings[0].substring(1), 10);
357
-
358
- queryAll(selectors.join(", ")).forEach(function(heading) {
359
- var level;
360
- var title;
361
- var item;
362
-
363
- if (heading.closest(".method_details .docstring")) return;
364
- if (heading.id === "filecontents") return;
365
-
366
- hasEntries = true;
367
- level = parseInt(heading.tagName.substring(1), 10);
368
-
369
- if (!heading.id) {
370
- var proposedId = heading.getAttribute("toc-id");
371
- if (!proposedId) {
372
- proposedId = heading.textContent.replace(/[^a-z0-9-]/gi, "_");
373
- if (query("#" + proposedId)) {
374
- proposedId += counter;
375
- counter += 1;
376
- }
377
- }
378
- heading.id = proposedId;
379
- }
380
-
381
- if (level > lastLevel) {
382
- while (level > lastLevel) {
383
- if (!currentItem) {
384
- currentItem = document.createElement("li");
385
- currentList.appendChild(currentItem);
386
- }
387
- var nestedList = document.createElement("ol");
388
- currentItem.appendChild(nestedList);
389
- currentList = nestedList;
390
- currentItem = null;
391
- lastLevel += 1;
392
- }
393
- } else if (level < lastLevel) {
394
- while (level < lastLevel && currentList.parentElement) {
395
- currentList = currentList.parentElement.parentElement;
396
- lastLevel -= 1;
397
- }
398
- }
399
-
400
- title = heading.getAttribute("toc-title") || heading.textContent;
401
- item = document.createElement("li");
402
- item.innerHTML = '<a href="#' + heading.id + '">' + title + "</a>";
403
- currentList.appendChild(item);
404
- currentItem = item;
405
- });
406
-
407
- if (!hasEntries) return;
408
-
409
- var toc = document.createElement("div");
410
- toc.id = "toc";
411
- toc.innerHTML =
412
- '<p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p>';
413
- content.insertBefore(toc, content.firstChild);
414
- toc.appendChild(topLevel);
415
-
416
- var hideLink = query("#toc .hide_toc");
417
- if (hideLink) {
418
- hideLink.addEventListener("click", function(event) {
419
- event.preventDefault();
420
- var list = query("#toc .top");
421
- var hidden = query("#toc").classList.toggle("hidden");
422
- toggleDisplay(list, !hidden);
423
- queryAll("#toc .title small").forEach(function(node) {
424
- toggleDisplay(node, hidden);
425
- });
426
- });
427
- }
428
- }
429
-
430
- function navResizer() {
431
- var resizer = document.getElementById("resizer");
432
-
433
- if (!resizer) return;
434
-
435
- if (!appState.navResizerBound) {
436
- resizer.addEventListener(
437
- "pointerdown",
438
- function(event) {
439
- resizer.setPointerCapture(event.pointerId);
440
- event.preventDefault();
441
- event.stopPropagation();
442
- },
443
- false
444
- );
445
- resizer.addEventListener(
446
- "pointerup",
447
- function(event) {
448
- resizer.releasePointerCapture(event.pointerId);
449
- event.preventDefault();
450
- event.stopPropagation();
451
- },
452
- false
453
- );
454
- resizer.addEventListener(
455
- "pointermove",
456
- function(event) {
457
- if ((event.buttons & 1) === 0) return;
458
-
459
- safeSessionStorage.navWidth = String(event.pageX);
460
- queryAll(".nav_wrap").forEach(function(node) {
461
- node.style.width = Math.max(200, event.pageX) + "px";
462
- });
463
- event.preventDefault();
464
- event.stopPropagation();
465
- },
466
- false
467
- );
468
-
469
- appState.navResizerBound = true;
470
- }
471
-
472
- if (safeSessionStorage.navWidth) {
473
- queryAll(".nav_wrap").forEach(function(node) {
474
- node.style.width =
475
- Math.max(200, parseInt(safeSessionStorage.navWidth, 10)) + "px";
476
- });
477
- }
478
- }
479
-
480
- function navExpander() {
481
- if (typeof pathId === "undefined") return;
482
-
483
- var frame = document.getElementById("nav");
484
- var token = ++appState.navExpanderToken;
485
-
486
- function postMessage() {
487
- if (token !== appState.navExpanderToken) return;
488
- expandNavPath(pathId);
489
- }
490
-
491
- clearTimeout(appState.navExpanderTimer);
492
- if (frame) frame.addEventListener("load", postMessage, { once: true });
493
- appState.navExpanderTimer = setTimeout(postMessage, 50);
494
- }
495
-
496
- function expandNavPath(path) {
497
- var frame = document.getElementById("nav");
498
-
499
- if (path == null || !frame || !frame.contentWindow) return;
500
- frame.contentWindow.postMessage({ action: "expand", path: path }, "*");
501
- }
502
-
503
- function focusHashTarget() {
504
- var hash = window.location.hash;
505
- if (!hash) return;
506
-
507
- var targetId = hash.slice(1);
508
- var decodedTargetId = targetId;
509
-
510
- try {
511
- decodedTargetId = decodeURIComponent(targetId);
512
- } catch (error) {}
513
-
514
- var target =
515
- document.getElementById(decodedTargetId) ||
516
- document.getElementById(targetId);
517
-
518
- if (target) target.scrollIntoView();
519
- }
520
-
521
- function mainFocus() {
522
- focusHashTarget();
523
- setTimeout(function() {
524
- var main = query("#main");
525
- if (main) main.focus();
526
- }, 10);
527
- }
528
-
529
- function navigationChange() {
530
- if (appState.navigationChangeBound) return;
531
-
532
- window.onpopstate = focusHashTarget;
533
- appState.navigationChangeBound = true;
534
- }
535
-
536
- window.__app = function() {
537
- ready(function() {
538
- navResizer();
539
- navExpander();
540
- createSourceLinks();
541
- createDefineLinks();
542
- createFullTreeLinks();
543
- searchFrameButtons();
544
- linkSummaries();
545
- summaryToggle();
546
- constantSummaryToggle();
547
- generateTOC();
548
- mainFocus();
549
- navigationChange();
550
- });
551
- };
552
-
553
- window.__app();
554
-
555
- if (!appState.navigationListenerBound) {
556
- window.addEventListener(
557
- "message",
558
- async function(event) {
559
- var navigationId;
560
- var response;
561
- var text;
562
- var parser;
563
- var doc;
564
- var classListLink;
565
- var contentNode;
566
- var content;
567
- var url;
568
- var hash;
569
-
570
- if (!event.data || event.data.action !== "navigate") return;
571
-
572
- navigationId = ++appState.latestNavigationId;
573
- expandNavPath(event.data.path);
574
- scheduleMainLoading(navigationId);
575
-
576
- try {
577
- response = await fetch(event.data.url);
578
- if (navigationId !== appState.latestNavigationId) return;
579
-
580
- text = await response.text();
581
- if (navigationId !== appState.latestNavigationId) return;
582
-
583
- parser = new DOMParser();
584
- doc = parser.parseFromString(text, "text/html");
585
- classListLink = document.getElementById("class_list_link");
586
- contentNode = doc.querySelector("#main");
587
- if (!contentNode) return;
588
- content = contentNode.innerHTML;
589
-
590
- document.querySelector("#main").innerHTML = content;
591
- document.title = doc.head.querySelector("title").innerText;
592
-
593
- queryAll("script", document.head).forEach(function(script) {
594
- if (
595
- !script.type ||
596
- (script.type.indexOf("text/javascript") !== -1 && !script.src)
597
- ) {
598
- script.remove();
599
- }
600
- });
601
-
602
- queryAll("script", doc.head).forEach(function(script) {
603
- if (
604
- !script.type ||
605
- (script.type.indexOf("text/javascript") !== -1 && !script.src)
606
- ) {
607
- var newScript = document.createElement("script");
608
- newScript.type = "text/javascript";
609
- newScript.textContent = script.textContent;
610
- document.head.appendChild(newScript);
611
- }
612
- });
613
-
614
- window.__app();
615
- if (navigationId !== appState.latestNavigationId) return;
616
-
617
- if (classListLink && document.getElementById("class_list_link")) {
618
- document.getElementById("class_list_link").className =
619
- classListLink.className;
620
- }
621
-
622
- url = new URL(event.data.url, "http://localhost");
623
- hash = decodeURIComponent(url.hash || "");
624
- if (hash) {
625
- var target = document.getElementById(hash.substring(1));
626
- if (target) target.scrollIntoView();
627
- }
628
- history.pushState({}, document.title, event.data.url);
629
- } finally {
630
- if (navigationId === appState.latestNavigationId) {
631
- cancelMainLoading();
632
- }
633
- }
634
- },
635
- false
636
- );
637
-
638
- appState.navigationListenerBound = true;
639
- }
1
+ (() => {
2
+ window.__yardAppState = window.__yardAppState || {
3
+ navigationListenerBound: false,
4
+ navigationChangeBound: false,
5
+ navResizerBound: false,
6
+ searchFrameGlobalsBound: false,
7
+ latestNavigationId: 0,
8
+ loadingIndicatorTimer: null,
9
+ loadingProgressTimer: null,
10
+ loadingProgressHideTimer: null,
11
+ navExpanderTimer: null,
12
+ navExpanderToken: 0,
13
+ currentUrl: window.location.href,
14
+ };
15
+ const appState = window.__yardAppState;
16
+ let safeLocalStorage = {};
17
+ let safeSessionStorage = {};
18
+
19
+ try {
20
+ safeLocalStorage = window.localStorage;
21
+ } catch (_error) {}
22
+
23
+ try {
24
+ safeSessionStorage = window.sessionStorage;
25
+ } catch (_error) {}
26
+
27
+ function query(selector, root) {
28
+ return (root || document).querySelector(selector);
29
+ }
30
+
31
+ function queryAll(selector, root) {
32
+ return Array.prototype.slice.call(
33
+ (root || document).querySelectorAll(selector),
34
+ );
35
+ }
36
+
37
+ function isVisible(element) {
38
+ if (!element) return false;
39
+ return window.getComputedStyle(element).display !== "none";
40
+ }
41
+
42
+ function toggleDisplay(element, visible, displayValue) {
43
+ if (!element) return;
44
+ element.style.display = visible ? displayValue || "" : "none";
45
+ }
46
+
47
+ function setMainLoading(loading) {
48
+ const body = document.body;
49
+ const main = query("#main");
50
+
51
+ if (body) body.classList.toggle("loading", !!loading);
52
+ if (!main) return;
53
+ main.classList.toggle("loading", !!loading);
54
+ main.setAttribute("aria-busy", loading ? "true" : "false");
55
+ }
56
+
57
+ function setLoadingProgress(progress) {
58
+ const indicator = query("#main_progress");
59
+
60
+ if (!indicator) return;
61
+ indicator.style.setProperty(
62
+ "--yard-progress",
63
+ `${Math.max(0, Math.min(100, progress))}%`,
64
+ );
65
+ }
66
+
67
+ function clearLoadingProgressTimers() {
68
+ clearTimeout(appState.loadingProgressTimer);
69
+ clearTimeout(appState.loadingProgressHideTimer);
70
+ appState.loadingProgressTimer = null;
71
+ appState.loadingProgressHideTimer = null;
72
+ }
73
+
74
+ function startLoadingProgress() {
75
+ const startedAt = Date.now();
76
+
77
+ clearLoadingProgressTimers();
78
+ setLoadingProgress(0);
79
+ setMainLoading(true);
80
+
81
+ function tick() {
82
+ const elapsed = Date.now() - startedAt;
83
+ let progress;
84
+
85
+ if (elapsed <= 1000) {
86
+ progress = (elapsed / 1000) * 99;
87
+ } else {
88
+ progress = 99 + Math.min(1, (elapsed - 1000) / 10000);
89
+ }
90
+
91
+ setLoadingProgress(progress);
92
+
93
+ if (progress < 100) {
94
+ appState.loadingProgressTimer = setTimeout(tick, 50);
95
+ } else {
96
+ appState.loadingProgressTimer = null;
97
+ }
98
+ }
99
+
100
+ tick();
101
+ }
102
+
103
+ function scheduleMainLoading(navigationId) {
104
+ clearTimeout(appState.loadingIndicatorTimer);
105
+ clearTimeout(appState.loadingProgressHideTimer);
106
+ appState.loadingProgressHideTimer = null;
107
+ appState.loadingIndicatorTimer = setTimeout(() => {
108
+ if (navigationId === appState.latestNavigationId) {
109
+ startLoadingProgress();
110
+ }
111
+ appState.loadingIndicatorTimer = null;
112
+ }, 400);
113
+ }
114
+
115
+ function cancelMainLoading() {
116
+ clearTimeout(appState.loadingIndicatorTimer);
117
+ appState.loadingIndicatorTimer = null;
118
+ clearTimeout(appState.loadingProgressTimer);
119
+ appState.loadingProgressTimer = null;
120
+ setLoadingProgress(100);
121
+ appState.loadingProgressHideTimer = setTimeout(() => {
122
+ setMainLoading(false);
123
+ setLoadingProgress(0);
124
+ appState.loadingProgressHideTimer = null;
125
+ }, 120);
126
+ }
127
+
128
+ function firstNextMatchingSibling(element, selector) {
129
+ let current = element;
130
+ while (current) {
131
+ current = current.nextElementSibling;
132
+ if (current?.matches(selector)) return current;
133
+ }
134
+ return null;
135
+ }
136
+
137
+ function ready(callback) {
138
+ if (document.readyState === "loading") {
139
+ document.addEventListener("DOMContentLoaded", callback, { once: true });
140
+ } else {
141
+ callback();
142
+ }
143
+ }
144
+
145
+ function createSourceLinks() {
146
+ queryAll(".method_details_list .source_code").forEach((sourceCode) => {
147
+ const toggleWrapper = document.createElement("span");
148
+ const link = document.createElement("a");
149
+
150
+ toggleWrapper.className = "showSource";
151
+ toggleWrapper.appendChild(document.createTextNode("["));
152
+ toggleWrapper.appendChild(link);
153
+ toggleWrapper.appendChild(document.createTextNode("]"));
154
+
155
+ link.href = "#";
156
+ link.className = "toggleSource";
157
+ link.textContent = "View source";
158
+
159
+ link.addEventListener("click", (event) => {
160
+ event.preventDefault();
161
+ const expanded = isVisible(sourceCode);
162
+ toggleDisplay(sourceCode, !expanded, "table");
163
+ link.textContent = expanded ? "View source" : "Hide source";
164
+ });
165
+
166
+ sourceCode.parentNode.insertBefore(toggleWrapper, sourceCode);
167
+ });
168
+ }
169
+
170
+ function createDefineLinks() {
171
+ queryAll(".defines").forEach((defines) => {
172
+ const toggleLink = document.createElement("a");
173
+ const summary = defines.parentElement.previousElementSibling;
174
+
175
+ toggleLink.href = "#";
176
+ toggleLink.className = "toggleDefines";
177
+ toggleLink.textContent = "more...";
178
+ defines.insertAdjacentText("afterend", " ");
179
+ defines.insertAdjacentElement("afterend", toggleLink);
180
+
181
+ toggleLink.addEventListener("click", (event) => {
182
+ event.preventDefault();
183
+ const expanded = toggleLink.dataset.expanded === "true";
184
+
185
+ if (!expanded) {
186
+ toggleLink.dataset.height = String(summary.offsetHeight);
187
+ defines.style.display = "inline";
188
+ summary.style.height = `${toggleLink.parentElement.offsetHeight}px`;
189
+ toggleLink.textContent = "(less)";
190
+ toggleLink.dataset.expanded = "true";
191
+ } else {
192
+ defines.style.display = "none";
193
+ if (toggleLink.dataset.height) {
194
+ summary.style.height = `${toggleLink.dataset.height}px`;
195
+ }
196
+ toggleLink.textContent = "more...";
197
+ toggleLink.dataset.expanded = "false";
198
+ }
199
+ });
200
+ });
201
+ }
202
+
203
+ function createFullTreeLinks() {
204
+ queryAll(".inheritanceTree").forEach((toggleLink) => {
205
+ const container = toggleLink.parentElement;
206
+ const tree = container.previousElementSibling;
207
+
208
+ toggleLink.addEventListener("click", (event) => {
209
+ event.preventDefault();
210
+ const expanded = toggleLink.dataset.expanded === "true";
211
+
212
+ if (!expanded) {
213
+ toggleLink.dataset.height = String(tree.offsetHeight);
214
+ container.classList.add("showAll");
215
+ toggleLink.textContent = "(hide)";
216
+ tree.style.height = `${container.offsetHeight}px`;
217
+ toggleLink.dataset.expanded = "true";
218
+ } else {
219
+ container.classList.remove("showAll");
220
+ if (toggleLink.dataset.height) {
221
+ tree.style.height = `${toggleLink.dataset.height}px`;
222
+ }
223
+ toggleLink.textContent = "show all";
224
+ toggleLink.dataset.expanded = "false";
225
+ }
226
+ });
227
+ });
228
+ }
229
+
230
+ function resetSearchFrame() {
231
+ const frame = query("#nav");
232
+
233
+ if (frame) frame.removeAttribute("style");
234
+ queryAll("#search a").forEach((link) => {
235
+ link.classList.remove("active");
236
+ link.classList.remove("inactive");
237
+ });
238
+ window.focus();
239
+ }
240
+
241
+ function toggleSearchFrame(linkElement, link) {
242
+ const frame = query("#nav");
243
+
244
+ if (!frame) return;
245
+
246
+ queryAll("#search a").forEach((searchLink) => {
247
+ searchLink.classList.remove("active");
248
+ searchLink.classList.add("inactive");
249
+ });
250
+
251
+ if (frame.getAttribute("src") === link && isVisible(frame)) {
252
+ frame.style.display = "none";
253
+ queryAll("#search a").forEach((searchLink) => {
254
+ searchLink.classList.remove("active");
255
+ searchLink.classList.remove("inactive");
256
+ });
257
+ } else {
258
+ linkElement.classList.add("active");
259
+ linkElement.classList.remove("inactive");
260
+ if (frame.getAttribute("src") !== link) frame.setAttribute("src", link);
261
+ frame.style.display = "block";
262
+ }
263
+ }
264
+
265
+ function searchFrameButtons() {
266
+ queryAll(".full_list_link").forEach((link) => {
267
+ if (link.dataset.yardSearchFrameBound === "true") return;
268
+
269
+ link.addEventListener("click", (event) => {
270
+ event.preventDefault();
271
+ toggleSearchFrame(link, link.getAttribute("href"));
272
+ });
273
+
274
+ link.dataset.yardSearchFrameBound = "true";
275
+ });
276
+
277
+ if (appState.searchFrameGlobalsBound) return;
278
+
279
+ window.addEventListener("message", (event) => {
280
+ if (event.data === "navEscape") resetSearchFrame();
281
+ });
282
+
283
+ window.addEventListener("resize", () => {
284
+ if (!isVisible(query("#search"))) resetSearchFrame();
285
+ });
286
+
287
+ appState.searchFrameGlobalsBound = true;
288
+ }
289
+
290
+ function linkSummaries() {
291
+ queryAll(".summary_signature").forEach((signature) => {
292
+ signature.addEventListener("click", (event) => {
293
+ if (event.target.closest("a")) return;
294
+ const link = signature.querySelector("a");
295
+ if (link) document.location = link.getAttribute("href");
296
+ });
297
+ });
298
+ }
299
+
300
+ function toggleSummaryCollection(toggleSelector, listSelector, cloneBuilder) {
301
+ queryAll(toggleSelector).forEach((toggleLink) => {
302
+ toggleLink.addEventListener("click", (event) => {
303
+ event.preventDefault();
304
+ safeLocalStorage.summaryCollapsed = toggleLink.textContent;
305
+
306
+ queryAll(toggleSelector).forEach((link) => {
307
+ link.textContent =
308
+ link.textContent === "collapse" ? "expand" : "collapse";
309
+
310
+ const container = link.parentElement.parentElement;
311
+ const next = firstNextMatchingSibling(container, listSelector);
312
+
313
+ if (!next) return;
314
+
315
+ if (next.classList.contains("compact")) {
316
+ const fullList = firstNextMatchingSibling(next, listSelector);
317
+ toggleDisplay(next, !isVisible(next));
318
+ toggleDisplay(fullList, !isVisible(fullList));
319
+ } else {
320
+ const compactList = cloneBuilder(next.cloneNode(true));
321
+ next.parentNode.insertBefore(compactList, next);
322
+ toggleDisplay(next, false);
323
+ }
324
+ });
325
+ });
326
+ });
327
+ }
328
+
329
+ function buildCompactSummary(list) {
330
+ list.className = "summary compact";
331
+
332
+ queryAll(".summary_desc, .note", list).forEach((node) => {
333
+ node.remove();
334
+ });
335
+
336
+ queryAll("a", list).forEach((link) => {
337
+ const strong = link.querySelector("strong");
338
+ if (strong) link.innerHTML = strong.innerHTML;
339
+ if (link.parentElement) link.parentElement.outerHTML = link.outerHTML;
340
+ });
341
+
342
+ return list;
343
+ }
344
+
345
+ function buildCompactConstants(list) {
346
+ list.className = "constants compact";
347
+
348
+ queryAll("dt", list).forEach((node) => {
349
+ const deprecated = !!node.querySelector(".deprecated");
350
+ node.classList.add("summary_signature");
351
+ node.textContent = node.textContent.split("=")[0];
352
+ if (deprecated) node.classList.add("deprecated");
353
+ });
354
+
355
+ queryAll("pre.code", list).forEach((pre) => {
356
+ const dtElement = pre.parentElement.previousElementSibling;
357
+ let tooltip = pre.textContent;
358
+ if (dtElement.classList.contains("deprecated")) {
359
+ tooltip = `Deprecated. ${tooltip}`;
360
+ }
361
+ dtElement.setAttribute("title", tooltip);
362
+ });
363
+
364
+ queryAll(".docstring, .tags, dd", list).forEach((node) => {
365
+ node.remove();
366
+ });
367
+
368
+ return list;
369
+ }
370
+
371
+ function summaryToggle() {
372
+ toggleSummaryCollection(
373
+ ".summary_toggle",
374
+ "ul.summary",
375
+ buildCompactSummary,
376
+ );
377
+
378
+ if (safeLocalStorage.summaryCollapsed === "collapse") {
379
+ const toggle = query(".summary_toggle");
380
+ if (toggle) toggle.click();
381
+ } else {
382
+ safeLocalStorage.summaryCollapsed = "expand";
383
+ }
384
+ }
385
+
386
+ function constantSummaryToggle() {
387
+ toggleSummaryCollection(
388
+ ".constants_summary_toggle",
389
+ "dl.constants",
390
+ buildCompactConstants,
391
+ );
392
+
393
+ if (safeLocalStorage.summaryCollapsed === "collapse") {
394
+ const toggle = query(".constants_summary_toggle");
395
+ if (toggle) toggle.click();
396
+ } else {
397
+ safeLocalStorage.summaryCollapsed = "expand";
398
+ }
399
+ }
400
+
401
+ function generateTOC() {
402
+ const fileContents = query("#filecontents");
403
+ const content = query("#content");
404
+
405
+ if (!fileContents || !content) return;
406
+ if (query("#toc", content)) return;
407
+
408
+ const topLevel = document.createElement("ol");
409
+ let currentList = topLevel;
410
+ let currentItem;
411
+ let counter = 0;
412
+ const headings = ["h2", "h3", "h4", "h5", "h6"];
413
+ let hasEntries = false;
414
+
415
+ topLevel.className = "top";
416
+
417
+ if (queryAll("#filecontents h1").length > 1) headings.unshift("h1");
418
+
419
+ const selectors = headings.map((tagName) => `#filecontents ${tagName}`);
420
+
421
+ let lastLevel = parseInt(headings[0].substring(1), 10);
422
+
423
+ queryAll(selectors.join(", ")).forEach((heading) => {
424
+ let level;
425
+
426
+ if (heading.closest(".method_details .docstring")) return;
427
+ if (heading.id === "filecontents") return;
428
+
429
+ hasEntries = true;
430
+ level = parseInt(heading.tagName.substring(1), 10);
431
+
432
+ if (!heading.id) {
433
+ let proposedId = heading.getAttribute("toc-id");
434
+ if (!proposedId) {
435
+ proposedId = heading.textContent.replace(/[^a-z0-9-]/gi, "_");
436
+ if (query(`#${proposedId}`)) {
437
+ proposedId += counter;
438
+ counter += 1;
439
+ }
440
+ }
441
+ heading.id = proposedId;
442
+ }
443
+
444
+ if (level > lastLevel) {
445
+ while (level > lastLevel) {
446
+ if (!currentItem) {
447
+ currentItem = document.createElement("li");
448
+ currentList.appendChild(currentItem);
449
+ }
450
+ const nestedList = document.createElement("ol");
451
+ currentItem.appendChild(nestedList);
452
+ currentList = nestedList;
453
+ currentItem = null;
454
+ lastLevel += 1;
455
+ }
456
+ } else if (level < lastLevel) {
457
+ while (level < lastLevel && currentList.parentElement) {
458
+ currentList = currentList.parentElement.parentElement;
459
+ lastLevel -= 1;
460
+ }
461
+ }
462
+
463
+ const title = heading.getAttribute("toc-title") || heading.textContent;
464
+ const item = document.createElement("li");
465
+ item.innerHTML = `<a href="#${heading.id}">${title}</a>`;
466
+ currentList.appendChild(item);
467
+ currentItem = item;
468
+ });
469
+
470
+ if (!hasEntries) return;
471
+
472
+ const toc = document.createElement("div");
473
+ toc.id = "toc";
474
+ toc.innerHTML =
475
+ '<p class="title hide_toc"><a href="#"><strong>Table of Contents</strong></a></p>';
476
+ content.insertBefore(toc, content.firstChild);
477
+ toc.appendChild(topLevel);
478
+
479
+ const hideLink = query("#toc .hide_toc");
480
+ if (hideLink) {
481
+ hideLink.addEventListener("click", (event) => {
482
+ event.preventDefault();
483
+ const list = query("#toc .top");
484
+ const hidden = query("#toc").classList.toggle("hidden");
485
+ toggleDisplay(list, !hidden);
486
+ queryAll("#toc .title small").forEach((node) => {
487
+ toggleDisplay(node, hidden);
488
+ });
489
+ });
490
+ }
491
+ }
492
+
493
+ function navResizer() {
494
+ const resizer = document.getElementById("resizer");
495
+
496
+ if (!resizer) return;
497
+
498
+ if (!appState.navResizerBound) {
499
+ resizer.addEventListener(
500
+ "pointerdown",
501
+ (event) => {
502
+ resizer.setPointerCapture(event.pointerId);
503
+ event.preventDefault();
504
+ event.stopPropagation();
505
+ },
506
+ false,
507
+ );
508
+ resizer.addEventListener(
509
+ "pointerup",
510
+ (event) => {
511
+ resizer.releasePointerCapture(event.pointerId);
512
+ event.preventDefault();
513
+ event.stopPropagation();
514
+ },
515
+ false,
516
+ );
517
+ resizer.addEventListener(
518
+ "pointermove",
519
+ (event) => {
520
+ if ((event.buttons & 1) === 0) return;
521
+
522
+ safeSessionStorage.navWidth = String(event.pageX);
523
+ queryAll(".nav_wrap").forEach((node) => {
524
+ node.style.width = `${Math.max(200, event.pageX)}px`;
525
+ });
526
+ event.preventDefault();
527
+ event.stopPropagation();
528
+ },
529
+ false,
530
+ );
531
+
532
+ appState.navResizerBound = true;
533
+ }
534
+
535
+ if (safeSessionStorage.navWidth) {
536
+ queryAll(".nav_wrap").forEach((node) => {
537
+ node.style.width = `${Math.max(200, parseInt(safeSessionStorage.navWidth, 10))}px`;
538
+ });
539
+ }
540
+ }
541
+
542
+ function navExpander(enabled) {
543
+ if (enabled === false) return;
544
+ if (typeof pathId === "undefined") return;
545
+
546
+ const frame = document.getElementById("nav");
547
+ const token = ++appState.navExpanderToken;
548
+
549
+ function postMessage() {
550
+ if (token !== appState.navExpanderToken) return;
551
+ expandNavPath(pathId);
552
+ }
553
+
554
+ clearTimeout(appState.navExpanderTimer);
555
+ if (frame) frame.addEventListener("load", postMessage, { once: true });
556
+ appState.navExpanderTimer = setTimeout(postMessage, 50);
557
+ }
558
+
559
+ function expandNavPath(path) {
560
+ const frame = document.getElementById("nav");
561
+
562
+ if (path == null || !frame || !frame.contentWindow) return;
563
+ frame.contentWindow.postMessage({ action: "expand", path: path }, "*");
564
+ }
565
+
566
+ function focusHashTarget(hashOverride) {
567
+ const hash =
568
+ typeof hashOverride === "string" ? hashOverride : window.location.hash;
569
+ if (!hash) return false;
570
+
571
+ const targetId = hash.slice(1);
572
+ let decodedTargetId = targetId;
573
+
574
+ try {
575
+ decodedTargetId = decodeURIComponent(targetId);
576
+ } catch (_error) {}
577
+
578
+ const target =
579
+ document.getElementById(decodedTargetId) ||
580
+ document.getElementById(targetId);
581
+
582
+ if (!target) return false;
583
+
584
+ target.scrollIntoView();
585
+ return true;
586
+ }
587
+
588
+ function resetMainScroll() {
589
+ const main = query("#main");
590
+
591
+ if (main) {
592
+ main.scrollTop = 0;
593
+ main.scrollLeft = 0;
594
+ }
595
+ window.scrollTo(0, 0);
596
+ }
597
+
598
+ function mainFocus() {
599
+ if (!focusHashTarget()) {
600
+ resetMainScroll();
601
+ }
602
+ setTimeout(() => {
603
+ const main = query("#main");
604
+ if (main) main.focus();
605
+ }, 10);
606
+ }
607
+
608
+ function navigationChange() {
609
+ if (appState.navigationChangeBound) return;
610
+
611
+ window.addEventListener("popstate", () => {
612
+ navigateTo(window.location.href, {
613
+ pushHistory: false,
614
+ syncNav: true,
615
+ });
616
+ });
617
+ appState.navigationChangeBound = true;
618
+ }
619
+
620
+ function sameDocumentUrl(left, right) {
621
+ const leftUrl = new URL(left, window.location.href);
622
+ const rightUrl = new URL(right, window.location.href);
623
+
624
+ return (
625
+ leftUrl.origin === rightUrl.origin &&
626
+ leftUrl.pathname === rightUrl.pathname &&
627
+ leftUrl.search === rightUrl.search
628
+ );
629
+ }
630
+
631
+ function contentPageUrl(url) {
632
+ const pageUrl = new URL(url, window.location.href);
633
+
634
+ pageUrl.hash = "";
635
+ return pageUrl.href;
636
+ }
637
+
638
+ function updatePageState(doc, pageWindow) {
639
+ const nextMain = doc.querySelector("#main");
640
+ const currentMain = query("#main");
641
+ const currentClassListLink = query("#class_list_link");
642
+ const currentClassListClassName = currentClassListLink
643
+ ? currentClassListLink.className
644
+ : null;
645
+
646
+ if (!nextMain || !currentMain) return false;
647
+
648
+ currentMain.innerHTML = nextMain.innerHTML;
649
+ document.title = doc.title;
650
+
651
+ if (currentClassListClassName && query("#class_list_link")) {
652
+ query("#class_list_link").className = currentClassListClassName;
653
+ }
654
+
655
+ if (pageWindow && typeof pageWindow.pathId !== "undefined") {
656
+ pathId = pageWindow.pathId;
657
+ }
658
+
659
+ if (pageWindow && typeof pageWindow.relpath !== "undefined") {
660
+ relpath = pageWindow.relpath;
661
+ }
662
+
663
+ return true;
664
+ }
665
+
666
+ function pageLoaderFrame() {
667
+ let frame = query("#page_loader");
668
+
669
+ if (frame) return frame;
670
+
671
+ frame = document.createElement("iframe");
672
+ frame.id = "page_loader";
673
+ frame.setAttribute("aria-hidden", "true");
674
+ frame.setAttribute("tabindex", "-1");
675
+ frame.style.display = "none";
676
+ document.body.appendChild(frame);
677
+ return frame;
678
+ }
679
+
680
+ function completeNavigation(url, options, pageWindow, pageDocument) {
681
+ const targetUrl = new URL(url, window.location.href);
682
+
683
+ if (!updatePageState(pageDocument, pageWindow)) return false;
684
+
685
+ window.__app({ rehydrateNav: false });
686
+
687
+ if (options.syncNav && typeof pathId !== "undefined") {
688
+ expandNavPath(pathId);
689
+ }
690
+
691
+ if (targetUrl.hash) {
692
+ focusHashTarget(targetUrl.hash);
693
+ } else {
694
+ resetMainScroll();
695
+ }
696
+
697
+ if (options.pushHistory) {
698
+ history.pushState({}, document.title, targetUrl.href);
699
+ }
700
+ appState.currentUrl = targetUrl.href;
701
+
702
+ return true;
703
+ }
704
+
705
+ function navigateTo(url, options) {
706
+ const navigationOptions = Object.assign(
707
+ { pushHistory: true, syncNav: false },
708
+ options || {},
709
+ );
710
+ const navigationId = ++appState.latestNavigationId;
711
+ const loader = pageLoaderFrame();
712
+ const resolvedUrl = new URL(url, window.location.href).href;
713
+ const loaderUrl = contentPageUrl(resolvedUrl);
714
+
715
+ if (sameDocumentUrl(appState.currentUrl, resolvedUrl)) {
716
+ const resolvedTargetUrl = new URL(resolvedUrl);
717
+
718
+ if (navigationOptions.pushHistory) {
719
+ history.pushState({}, document.title, resolvedUrl);
720
+ }
721
+ appState.currentUrl = resolvedUrl;
722
+ if (resolvedTargetUrl.hash) {
723
+ focusHashTarget(resolvedTargetUrl.hash);
724
+ } else {
725
+ resetMainScroll();
726
+ }
727
+ return;
728
+ }
729
+
730
+ scheduleMainLoading(navigationId);
731
+
732
+ loader.onload = () => {
733
+ let pageWindow;
734
+ let pageDocument;
735
+ let completed = false;
736
+
737
+ if (navigationId !== appState.latestNavigationId) return;
738
+
739
+ try {
740
+ pageWindow = loader.contentWindow;
741
+ pageDocument = loader.contentDocument || pageWindow.document;
742
+ completed = completeNavigation(
743
+ resolvedUrl,
744
+ navigationOptions,
745
+ pageWindow,
746
+ pageDocument,
747
+ );
748
+ } catch (_error) {
749
+ window.location.href = resolvedUrl;
750
+ return;
751
+ } finally {
752
+ if (navigationId === appState.latestNavigationId) {
753
+ cancelMainLoading();
754
+ }
755
+ if (completed) {
756
+ loader.onload = null;
757
+ loader.removeAttribute("src");
758
+ }
759
+ }
760
+ };
761
+
762
+ loader.src = loaderUrl;
763
+ }
764
+
765
+ window.__app = (options) => {
766
+ const appOptions = options || {};
767
+ ready(() => {
768
+ navResizer();
769
+ navExpander(appOptions.rehydrateNav !== false);
770
+ createSourceLinks();
771
+ createDefineLinks();
772
+ createFullTreeLinks();
773
+ searchFrameButtons();
774
+ linkSummaries();
775
+ summaryToggle();
776
+ constantSummaryToggle();
777
+ generateTOC();
778
+ mainFocus();
779
+ navigationChange();
780
+ });
781
+ };
782
+
783
+ window.__app();
784
+
785
+ if (!appState.navigationListenerBound) {
786
+ window.addEventListener(
787
+ "message",
788
+ (event) => {
789
+ if (!event.data || event.data.action !== "navigate") return;
790
+
791
+ navigateTo(event.data.url, {
792
+ pushHistory: true,
793
+ syncNav: false,
794
+ });
795
+ },
796
+ false,
797
+ );
798
+
799
+ appState.navigationListenerBound = true;
800
+ }
640
801
  })();