emailengine-app 2.77.0 → 2.78.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (94) hide show
  1. package/.github/workflows/test.yml +80 -0
  2. package/.release-please-manifest.json +1 -1
  3. package/CHANGELOG.md +31 -0
  4. package/bin/emailengine.js +1 -1
  5. package/data/google-crawlers.json +1 -1
  6. package/encrypt.js +1 -1
  7. package/lib/account/expected-identity.js +88 -0
  8. package/lib/account.js +75 -26
  9. package/lib/api-reference/format.js +14 -0
  10. package/lib/api-reference/index.js +24 -7
  11. package/lib/api-reference/model.js +4 -2
  12. package/lib/api-routes/account-routes.js +19 -2
  13. package/lib/api-routes/behavior-notes.js +3 -0
  14. package/lib/append-list.js +3 -14
  15. package/lib/arf-detect.js +23 -1
  16. package/lib/autodetect-imap-settings.js +40 -16
  17. package/lib/base32.js +30 -0
  18. package/lib/bounce-detect.js +182 -62
  19. package/lib/egress-filter.js +89 -8
  20. package/lib/email-client/base-client.js +8 -72
  21. package/lib/email-client/gmail-client.js +3 -3
  22. package/lib/email-client/imap/listing-diff.js +3 -3
  23. package/lib/email-client/imap/mailbox.js +5 -69
  24. package/lib/email-client/imap-client.js +3 -2
  25. package/lib/email-client/message-builder.js +13 -13
  26. package/lib/email-client/outlook-client.js +1 -1
  27. package/lib/export.js +1 -1
  28. package/lib/gateway.js +1 -1
  29. package/lib/get-raw-email.js +1 -1
  30. package/lib/imapproxy/imap-core/lib/imap-connection.js +2 -2
  31. package/lib/imapproxy/imap-core/lib/imap-server.js +2 -2
  32. package/lib/imapproxy/imap-server.js +13 -3
  33. package/lib/license-beacon.js +1 -1
  34. package/lib/llm-pre-process.js +1 -1
  35. package/lib/msgpack.js +62 -0
  36. package/lib/oauth/decode-jwt-payload.js +39 -0
  37. package/lib/oauth/outlook-identity.js +61 -0
  38. package/lib/oauth/retry-setup.js +38 -0
  39. package/lib/oauth2-apps.js +1 -1
  40. package/lib/outbox.js +66 -3
  41. package/lib/pre-process.js +1 -1
  42. package/lib/read-env-value.js +37 -0
  43. package/lib/schemas.js +12 -0
  44. package/lib/templates.js +1 -1
  45. package/lib/tokens.js +1 -1
  46. package/lib/tools.js +117 -48
  47. package/lib/totp.js +67 -0
  48. package/lib/ui-routes/account-routes.js +91 -15
  49. package/lib/ui-routes/admin-config-routes.js +2 -7
  50. package/lib/ui-routes/auth-routes.js +6 -24
  51. package/lib/ui-routes/reference-routes.js +8 -5
  52. package/lib/ui-routes/route-helpers.js +28 -0
  53. package/lib/utils/is-email.js +34 -0
  54. package/lib/utils/to-camel-case.js +17 -0
  55. package/lib/webhook-egress.js +37 -0
  56. package/lib/webhooks.js +1 -1
  57. package/package.json +22 -24
  58. package/sbom.json +1 -0
  59. package/server.js +1 -1
  60. package/static/css/flyonui.css +1 -1
  61. package/static/css/public.css +3 -0
  62. package/static/css/src/app.tailwind.css +23 -0
  63. package/static/js/app.js +69 -0
  64. package/static/js/reference.js +286 -1
  65. package/static/licenses.html +656 -1558
  66. package/translations/README.md +64 -0
  67. package/translations/de.mo +0 -0
  68. package/translations/de.po +164 -120
  69. package/translations/en.po +200 -161
  70. package/translations/et.mo +0 -0
  71. package/translations/et.po +163 -120
  72. package/translations/fr.mo +0 -0
  73. package/translations/fr.po +163 -120
  74. package/translations/ja.mo +0 -0
  75. package/translations/ja.po +163 -120
  76. package/translations/messages.pot +76 -46
  77. package/translations/nl.mo +0 -0
  78. package/translations/nl.po +164 -120
  79. package/translations/pl.mo +0 -0
  80. package/translations/pl.po +163 -120
  81. package/views/account-identity-error.hbs +34 -0
  82. package/views/accounts/edit.hbs +1 -0
  83. package/views/accounts/register/imap.hbs +12 -2
  84. package/views/layout/app.hbs +29 -5
  85. package/views/oauth-scope-error.hbs +1 -1
  86. package/views/partials/reference/nav.hbs +36 -9
  87. package/views/partials/reference/operation.hbs +1 -1
  88. package/views/partials/reference/schema-node.hbs +1 -1
  89. package/views/partials/reference/token-alert.hbs +35 -10
  90. package/views/reference/index.hbs +1 -1
  91. package/workers/api.js +157 -87
  92. package/workers/imap.js +1 -1
  93. package/workers/submit.js +1 -1
  94. package/workers/webhooks.js +2 -13
@@ -874,6 +874,9 @@ dialog.ee-modal.ee-modal-wide {
874
874
  .ee-dl dd {
875
875
  margin: 0 0 0.5rem;
876
876
  min-width: 0;
877
+ /* Values here can be email addresses, which offer no natural break opportunity and would otherwise
878
+ run past the single-column grid on a narrow screen. */
879
+ overflow-wrap: anywhere;
877
880
  }
878
881
 
879
882
  @media (min-width: 640px) {
@@ -96,6 +96,18 @@
96
96
  }
97
97
 
98
98
  @layer base {
99
+ /* The admin shell's topbar is sticky, and a page may stick a band of its own under it
100
+ * (the API reference's "no access token" banner, whose measured height static/js/
101
+ * reference.js publishes). Telling the scroller about that inset covers every way
102
+ * something is scrolled into view - fragment links, scrollIntoView, find-in-page, the
103
+ * focus moving through a Try it panel - instead of only the classes that carry a
104
+ * scroll-margin of their own. On the class rather than on html because the login and
105
+ * public layouts load this stylesheet too and have no topbar to clear; the class is on
106
+ * <html> in views/layout/app.hbs. */
107
+ .ee-app-chrome {
108
+ scroll-padding-top: calc(var(--spacing-topbar) + var(--ee-sticky-band-h, 0px));
109
+ }
110
+
99
111
  /* Tailwind preflight leaves hr at "1px solid currentColor" - a harsh
100
112
  * full-contrast line in both themes; default every hr to the standard
101
113
  * content-border token instead of classing each instance */
@@ -241,6 +253,17 @@
241
253
  padding-inline-start: 0.75rem;
242
254
  }
243
255
 
256
+ /* Room to breathe above a jump target - operations linked from the sidebar and from
257
+ * #operationId, property rows from #operation.body.field. The sticky chrome above them is
258
+ * NOT in here: that is scroll-padding on the scroller (.ee-app-chrome in @layer base), and
259
+ * counting it twice would park every deep link a band's height below where it belongs.
260
+ * Also keep any scroll-mt-* utility off these elements - utilities are emitted after this
261
+ * layer and would silently replace it. */
262
+ .ee-ref-op,
263
+ .ee-ref-prop {
264
+ scroll-margin-top: 2rem;
265
+ }
266
+
244
267
  /* Deep-link icons (reference/anchor-link), on operation headings and on every
245
268
  * property row. One definition instead of the utility string repeated at every
246
269
  * call site - a tag page renders up to 434 of these. */
package/static/js/app.js CHANGED
@@ -219,6 +219,75 @@ document.addEventListener('DOMContentLoaded', () => {
219
219
  });
220
220
  }
221
221
 
222
+ // Secondary navigation column (views/layout/app.hbs): a full column beside the content
223
+ // from lg up, a disclosure below that. aria-expanded on the button is the whole state -
224
+ // the panel derives its visibility from it in CSS (peer-aria-expanded:block), so there is
225
+ // no second flag to keep in step. Above lg the button is display:none and lg:block on the
226
+ // panel outranks the peer rule, so the writes below are inert rather than wrong there.
227
+ let secondaryNavToggle = document.getElementById('secondary-nav-toggle');
228
+ let secondaryNavPanel = document.getElementById('secondary-nav-panel');
229
+ if (secondaryNavToggle && secondaryNavPanel) {
230
+ let setSecondaryNav = expanded => secondaryNavToggle.setAttribute('aria-expanded', String(expanded));
231
+
232
+ secondaryNavToggle.addEventListener('click', () => setSecondaryNav(secondaryNavToggle.getAttribute('aria-expanded') !== 'true'));
233
+
234
+ // Closing takes focus with it when the caret is inside the panel: the subtree becomes
235
+ // display:none, and focus would fall back to <body> - the reader's next Tab would
236
+ // restart from the top of the page. Hand it back to the control they came from.
237
+ let closeSecondaryNav = () => {
238
+ let focused = document.activeElement;
239
+ setSecondaryNav(false);
240
+ if (focused && secondaryNavPanel.contains(focused)) {
241
+ secondaryNavToggle.focus();
242
+ }
243
+ };
244
+
245
+ // Page scripts have business with this too - the reference's filter shortcut has to
246
+ // open the panel before it can focus the field inside it, and its group rows behave
247
+ // differently depending on which mode the column is in. Publishing the facts they need
248
+ // keeps the toggle's id, and the fact that a click is what opens it, in this file.
249
+ // `collapsible` reads the button's own box: it is lg:hidden, so being laid out at all
250
+ // is the answer, and the breakpoint stays in the stylesheet.
251
+ window.uiSecondaryNav = {
252
+ // the elements too: the toggle so a page script can watch its box for the mode
253
+ // change, the panel because below lg it is the scroller the nav lives in
254
+ toggle: secondaryNavToggle,
255
+ panel: secondaryNavPanel,
256
+ collapsible: () => !!secondaryNavToggle.offsetParent,
257
+ open: () => setSecondaryNav(true),
258
+ close: closeSecondaryNav
259
+ };
260
+
261
+ secondaryNavPanel.addEventListener('click', event => {
262
+ // A link to another page reloads and closes this anyway, but an in-page anchor
263
+ // does not - it would leave the panel expanded over the section just jumped to.
264
+ // Closing before the browser acts on the fragment also keeps the landing position
265
+ // right: the page shrinks first and the scroll is measured after.
266
+ //
267
+ // Two links are left alone: one something else already handled (defaultPrevented -
268
+ // the reference's group rows open their own list in place), and one opened
269
+ // elsewhere by a modifier, which leaves this page exactly where it was.
270
+ if (event.defaultPrevented || event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
271
+ return;
272
+ }
273
+
274
+ if (event.target.closest('a')) {
275
+ closeSecondaryNav();
276
+ }
277
+ });
278
+
279
+ // Escape is the way out of any disclosure. Without it the only way to put the panel
280
+ // away is to find the row that opened it, which by then may be a screen above. Same
281
+ // rule as the click handler: a keystroke something else has already acted on is not
282
+ // ours - the reference's filter takes Escape to clear its query, and clearing a query
283
+ // should not also close the panel it was being typed into.
284
+ document.addEventListener('keydown', event => {
285
+ if (event.key === 'Escape' && !event.defaultPrevented && secondaryNavToggle.getAttribute('aria-expanded') === 'true') {
286
+ closeSecondaryNav();
287
+ }
288
+ });
289
+ }
290
+
222
291
  // show or hide the error tooltip attached to a state badge (the badge sits
223
292
  // inside a ui/state-badge tooltip wrapper). The empty state is gated with
224
293
  // ee-tooltip-empty on the wrapper, not with hidden on the content -
@@ -76,6 +76,59 @@
76
76
 
77
77
  const minutesLeft = expires => Math.max(0, Math.round((expires - Date.now()) / 60000));
78
78
 
79
+ // The "no token set" banner sticks below the topbar (reference/token-alert.hbs), so it
80
+ // adds to what a jump target has to clear. Its measured height is published to the
81
+ // stylesheet rather than hard-coded there, because the band wraps to two rows on a narrow
82
+ // viewport - the layout's scroll-padding (.ee-app-chrome) adds it to the scroller's top
83
+ // inset. Kept as a number too, for the scroll spy: that line moves with the same inset,
84
+ // and reading it back out of the cascade on every scrolled frame would force a style
85
+ // recalc to do it.
86
+ let alertHeight = 0;
87
+
88
+ // Written only when it actually changes. Setting an inherited custom property on the root
89
+ // element invalidates style for the whole document - measured at ~7ms on a tag page, and
90
+ // the same with no rule reading the property at all, so this is the cost of the write
91
+ // itself rather than of the 434 rows that resolve it. The observer below makes an
92
+ // unchanged republish easy to hit, since it fires on width too, which moves on every frame
93
+ // of a resize drag while the height sits still.
94
+ const publishAlertHeight = alert => {
95
+ // `hidden` is display: none, so a hidden band measures 0 without a special case
96
+ const height = alert.offsetHeight;
97
+ if (height === alertHeight) {
98
+ return;
99
+ }
100
+
101
+ alertHeight = height;
102
+ document.documentElement.style.setProperty('--ee-sticky-band-h', `${height}px`);
103
+ return true;
104
+ };
105
+
106
+ // A band that changes height after revealTarget has landed a deep link leaves the section
107
+ // under a band that is opaque, not merely offset - the web font swapping in and rewrapping
108
+ // the warning is the case that hits a cold load. Re-land it, but only while the reader is
109
+ // still exactly where the jump left them: past that they have scrolled on, and yanking the
110
+ // page back would be worse than the offset.
111
+ const relandIfUnmoved = () => {
112
+ if (landedAt !== null && Math.round(window.scrollY) === landedAt) {
113
+ revealTarget();
114
+ }
115
+ };
116
+
117
+ // Show and hide are published by paintTokenStatus rather than left to the observer below:
118
+ // both run at DOMContentLoaded, and revealTarget scrolls to the deep link at `load` with
119
+ // whatever margin is in effect by then. This covers the band changing height on its own,
120
+ // which it does when a viewport narrow enough to wrap it is resized.
121
+ const initAlertHeight = () => {
122
+ const alert = document.getElementById('ref-token-alert');
123
+ if (alert) {
124
+ new ResizeObserver(() => {
125
+ if (publishAlertHeight(alert)) {
126
+ relandIfUnmoved();
127
+ }
128
+ }).observe(alert);
129
+ }
130
+ };
131
+
79
132
  // Repaints the always-visible status in the sidebar, and shows the Clear control on
80
133
  // the overview page only while there is something to clear.
81
134
  const paintTokenStatus = () => {
@@ -98,7 +151,7 @@
98
151
  const alert = document.getElementById('ref-token-alert');
99
152
  if (alert) {
100
153
  alert.classList.toggle('hidden', !!entry);
101
- alert.classList.toggle('flex', !entry);
154
+ publishAlertHeight(alert);
102
155
  }
103
156
  };
104
157
 
@@ -150,6 +203,10 @@
150
203
  window.addEventListener('load', fn);
151
204
  };
152
205
 
206
+ // Where the last deep-link jump left the page, so a band that grows afterwards can tell
207
+ // "the reader has not moved yet" from "they have scrolled on". Null until one happens.
208
+ let landedAt = null;
209
+
153
210
  // Deep links point at a single schema property ("#accountCreate.body.imap.tls"), which
154
211
  // can sit inside collapsed <details> groups and an inactive response tab - neither of
155
212
  // which the browser can scroll to, because they have no layout box. Everything on the
@@ -181,6 +238,83 @@
181
238
  }
182
239
 
183
240
  target.scrollIntoView({ block: 'start' });
241
+ landedAt = Math.round(window.scrollY);
242
+ };
243
+
244
+ // Group rows in the nav. As a column they are plain links to the group's page. Below the
245
+ // layout's lg breakpoint the whole nav is a disclosure, and a link there is a bad deal: the
246
+ // tap that was meant to look inside a group loads its page and takes the menu with it. So
247
+ // in that mode the row opens its own operation list instead, and the reader picks the
248
+ // endpoint they actually wanted - which is the only navigation that ends the menu.
249
+ //
250
+ // Which mode the column is in is the layout's own question, answered by the small API
251
+ // static/js/app.js publishes for it.
252
+ const initTagRows = () => {
253
+ const list = document.getElementById('ref-tag-list');
254
+ const nav = window.uiSecondaryNav;
255
+ if (!list || !nav) {
256
+ return;
257
+ }
258
+
259
+ list.addEventListener('click', event => {
260
+ // aria-controls is what a group row has and an operation row does not
261
+ const row = event.target.closest('a[aria-controls]');
262
+ if (!row || !nav.collapsible()) {
263
+ return;
264
+ }
265
+
266
+ // A modified click is asking for the group's page in a new tab or window, which is
267
+ // still what the href says. Swallowing it would make the row mean one thing to the
268
+ // left button and another to every other way of opening a link.
269
+ if (event.metaKey || event.ctrlKey || event.shiftKey || event.altKey) {
270
+ return;
271
+ }
272
+
273
+ // preventDefault is also what tells the layout's panel handler to leave the menu
274
+ // open: a link that did not navigate has not finished with the reader.
275
+ event.preventDefault();
276
+
277
+ const expand = row.getAttribute('aria-expanded') !== 'true';
278
+ const before = row.getBoundingClientRect().top;
279
+
280
+ // One group at a time, which is the state the page is served in and keeps the menu
281
+ // to a screen or two. Opening all nineteen would put 3000px of navigation above the
282
+ // page, with the control to put it away scrolled off the top.
283
+ for (const open of list.querySelectorAll('a[aria-expanded="true"]')) {
284
+ open.setAttribute('aria-expanded', 'false');
285
+ }
286
+
287
+ row.setAttribute('aria-expanded', String(expand));
288
+
289
+ // Closing a group above this one pulls the list out from under the finger that
290
+ // just tapped it - by the height of whatever was open, which is most of a screen.
291
+ // Put the row back where it was touched.
292
+ const drift = row.getBoundingClientRect().top - before;
293
+ if (drift) {
294
+ if (nav.panel.scrollHeight > nav.panel.clientHeight) {
295
+ nav.panel.scrollTop += drift;
296
+ } else {
297
+ window.scrollBy(0, drift);
298
+ }
299
+ }
300
+ });
301
+
302
+ // Crossing back into column mode resets the rows to what the server renders: there
303
+ // lg:block shows the group the page is on and hides every other, so a row still saying
304
+ // "expanded" from a narrow window would announce the opposite of what is on screen -
305
+ // and no click can reconcile it, because the rows are plain links at that width. The
306
+ // active group is the one carrying the spy hook. Watching the toggle's box is how this
307
+ // hears the mode change without naming the breakpoint.
308
+ new ResizeObserver(() => {
309
+ if (nav.collapsible()) {
310
+ return;
311
+ }
312
+
313
+ for (const row of list.querySelectorAll('a[aria-controls]')) {
314
+ const ops = document.getElementById(row.getAttribute('aria-controls'));
315
+ row.setAttribute('aria-expanded', String(!!ops && ops.classList.contains('ee-ref-op-nav')));
316
+ }
317
+ }).observe(nav.toggle);
184
318
  };
185
319
 
186
320
  // Resolved once - the platform cannot change, and the shortcut check runs on every
@@ -342,11 +476,159 @@
342
476
  }
343
477
 
344
478
  event.preventDefault();
479
+
480
+ // Below the layout's lg breakpoint this whole column is a disclosure, and focusing
481
+ // an input inside a display:none subtree does nothing at all - which is the width
482
+ // where a narrow window most needs the filter. Open it on the way to the field.
483
+ if (window.uiSecondaryNav && window.uiSecondaryNav.collapsible()) {
484
+ window.uiSecondaryNav.open();
485
+ }
486
+
345
487
  input.focus();
346
488
  input.select();
347
489
  });
348
490
  };
349
491
 
492
+ // Marks the operation you are currently reading in the sidebar.
493
+ //
494
+ // Slack between the line an operation has to cross and the point it parks at when linked
495
+ // to directly. Without it the two are equal and sub-pixel rounding decides which section
496
+ // a deep link marks; with it, landing on a section always marks that section.
497
+ const SPY_SLACK = 16;
498
+
499
+ const initScrollSpy = () => {
500
+ const list = document.querySelector('.ee-ref-op-nav');
501
+ const panel = list && list.closest('aside');
502
+ if (!panel) {
503
+ return;
504
+ }
505
+
506
+ // Walked in DOCUMENT order, from the sections rather than from the nav. The two happen
507
+ // to agree today - both come from tag.operations - but only this direction is true by
508
+ // construction, and the scan below is meaningless if the order is wrong. Sorting the
509
+ // nav some other way later would silently break a nav-ordered list.
510
+ //
511
+ // One array of pairs, not a Map plus a copy of its keys: every use wants both halves.
512
+ const entries = [];
513
+ for (const section of document.querySelectorAll('.ee-ref-op[id]')) {
514
+ const link = list.querySelector(`a[href="#${CSS.escape(section.id)}"]`);
515
+ if (link) {
516
+ entries.push({ link, section });
517
+ }
518
+ }
519
+
520
+ if (!entries.length) {
521
+ return;
522
+ }
523
+
524
+ const last = entries[entries.length - 1];
525
+
526
+ // Read from the cascade rather than restated as a number here: a linked section parks
527
+ // at the scroller's own top inset (the sticky chrome, html's scroll-padding-top) plus
528
+ // its scroll-margin, and a spy line that disagreed with the two would mark the wrong
529
+ // row on arrival. Whatever the banner contributes right now is taken back out and
530
+ // re-added per read: that makes this independent of whether the banner has been
531
+ // measured yet, and follows it disappearing when a token is minted, which shortens the
532
+ // inset without the page reloading.
533
+ const staticLine =
534
+ parseFloat(window.getComputedStyle(document.documentElement).scrollPaddingTop || '0') -
535
+ alertHeight +
536
+ parseFloat(window.getComputedStyle(entries[0].section).scrollMarginTop || '0') +
537
+ SPY_SLACK;
538
+
539
+ const current = () => {
540
+ // Recomputed from scratch every time rather than tracked incrementally, so it cannot
541
+ // drift out of step with the page
542
+ const line = staticLine + alertHeight;
543
+ const found = entries.findLast(entry => entry.section.getBoundingClientRect().top <= line) || entries[0];
544
+
545
+ // A final section shorter than the space below it never reaches the line, so it
546
+ // would never light up. Only the pick just before it can be wrong this way, which
547
+ // keeps the scrollHeight read - the one most likely to force layout, on a page whose
548
+ // height moves as code blocks highlight - off all but the last screenful.
549
+ if (found === entries[entries.length - 2] && window.innerHeight + window.scrollY >= document.documentElement.scrollHeight - 2) {
550
+ return last;
551
+ }
552
+
553
+ return found;
554
+ };
555
+
556
+ // Scrolls the sidebar itself rather than calling scrollIntoView, which also scrolls the
557
+ // window - that would move the sections being measured and could oscillate. Returns the
558
+ // delta instead of applying it so paint() can finish measuring before it writes.
559
+ const panelDelta = link => {
560
+ // Only the full-height column scrolls on its own. Below the layout's lg breakpoint
561
+ // the same markup is a disclosure in normal page flow, with nothing to scroll -
562
+ // asking whether it overflows answers that without naming the breakpoint again.
563
+ if (panel.scrollHeight <= panel.clientHeight) {
564
+ return 0;
565
+ }
566
+
567
+ // While the filter has input the whole tag list is display:none, so these links
568
+ // have no box at all - and a zero rect against the panel's top reads as "scrolled
569
+ // far above", which would drag the sidebar up a row at a time behind the results.
570
+ if (!link.offsetParent) {
571
+ return 0;
572
+ }
573
+
574
+ const linkBox = link.getBoundingClientRect();
575
+ const panelBox = panel.getBoundingClientRect();
576
+
577
+ if (linkBox.top < panelBox.top) {
578
+ return linkBox.top - panelBox.top - 8;
579
+ }
580
+ if (linkBox.bottom > panelBox.bottom) {
581
+ return linkBox.bottom - panelBox.bottom + 8;
582
+ }
583
+ return 0;
584
+ };
585
+
586
+ let marked = null;
587
+
588
+ const paint = () => {
589
+ const entry = current();
590
+ if (entry === marked) {
591
+ return;
592
+ }
593
+
594
+ // Measured before anything is written: setting aria-current restyles the link, so
595
+ // reading its box afterwards would force a synchronous style and layout pass at the
596
+ // exact moment the marker moves.
597
+ const delta = panelDelta(entry.link);
598
+
599
+ if (marked) {
600
+ marked.link.removeAttribute('aria-current');
601
+ }
602
+
603
+ marked = entry;
604
+ // `location` rather than `page`: the tag entry above is the current page, this is a
605
+ // position within it
606
+ entry.link.setAttribute('aria-current', 'location');
607
+
608
+ if (delta) {
609
+ panel.scrollTop += delta;
610
+ }
611
+ };
612
+
613
+ let queued = false;
614
+ const schedule = () => {
615
+ if (queued) {
616
+ return;
617
+ }
618
+ queued = true;
619
+ // Reads happen inside the frame callback, before the browser's own style and layout
620
+ // phase, so the flush they force is work the frame was going to do anyway
621
+ window.requestAnimationFrame(() => {
622
+ queued = false;
623
+ paint();
624
+ });
625
+ };
626
+
627
+ window.addEventListener('scroll', schedule, { passive: true });
628
+ window.addEventListener('resize', schedule, { passive: true });
629
+ paint();
630
+ };
631
+
350
632
  // Code sample language, remembered across operations and page loads.
351
633
  //
352
634
  // localStorage, not sessionStorage (which is what the try-it token uses): this is a
@@ -719,10 +1001,13 @@
719
1001
  document.addEventListener('DOMContentLoaded', () => {
720
1002
  initHighlighting();
721
1003
  initFilter();
1004
+ initTagRows();
1005
+ initScrollSpy();
722
1006
  initSampleTabs();
723
1007
  initTryIt();
724
1008
  initMint();
725
1009
  initTokenForm();
1010
+ initAlertHeight();
726
1011
  paintTokenStatus();
727
1012
 
728
1013
  // On load rather than here: a target inside an inactive response tab needs the tab