@jsenv/navi 0.29.467 → 0.29.468

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.
@@ -33416,85 +33416,6 @@ const onDocumentClick = (clickEvent) => {
33416
33416
 
33417
33417
  installImportMetaCssBuild(import.meta);
33418
33418
 
33419
- /**
33420
- * The furniture around the pages — the fixed bars, and the popups standing
33421
- * over them in the top layer — photographed with them for the length of a
33422
- * route transition, so that a piece of it belonging to ONE of the two states
33423
- * takes part in the movement instead of appearing or vanishing in a frame.
33424
- *
33425
- * Whether a bar is the frame or part of what changes is a fact about the PAIR
33426
- * of states, never about the bar: the top bar of a list is the frame while one
33427
- * goes into a row of that list, and part of what changes when the next page
33428
- * takes the whole screen. So nothing is declared — a name is written on every
33429
- * bar for the length of the movement, and the browser derives the rest:
33430
- *
33431
- * - a bar the two states SHARE is one element wearing one name on both sides.
33432
- * The browser pairs the two pictures into one group and holds it where it
33433
- * stands: the frame, and the pages move behind it exactly as before.
33434
- * - a bar only one state has never meets a counterpart. It belongs to the page
33435
- * that has it, so it travels with that page — leaving by the keyframes the
33436
- * page being left leaves by, arriving by the ones the page arriving arrives
33437
- * by — instead of going out with the render. Over that page, as it is at
33438
- * rest: the page runs under it, and what it paints outside its box (a button
33439
- * standing up out of a tab bar) is not cut by its own page. Under the pages
33440
- * only when its page is covered by the other one — a cover-* movement — so
33441
- * the sheet comes over it; a popup over everything, standing where it
33442
- * stands in the document (see the z-order in route_transition.jsx). Which
33443
- * side a bar is on is said by a class on its group, written here.
33444
- *
33445
- * A popup shown in the top layer is furniture of the same kind, and its case
33446
- * is the sharper one: it is a DOM descendant of the area, yet painted outside
33447
- * the area's picture, so being captured on its own is the only way it is on
33448
- * screen at all for those few hundred milliseconds (layout/popup_css.js). One
33449
- * the two states share holds where it stands, one only a single state has
33450
- * travels with that state's page — the same two outcomes, derived the same way.
33451
- *
33452
- * Which keyframes those are is published by the movement itself
33453
- * (--navi-route-transition-leave / -enter, see route_transition.jsx): a
33454
- * selector cannot say "the bars that have no counterpart" — the names are per
33455
- * element, so there is nothing static to write — so the rule is written for
33456
- * the length of the movement, over the names this one turned out to have.
33457
- *
33458
- * The name is per ELEMENT and kept for the element's whole life, which is what
33459
- * makes "shared" mean shared: several bars can live on one edge
33460
- * (layout/fixed_bar/fixed_bar_space.js), so a bar leaving and another one
33461
- * arriving on that same edge are two names and two movements, not one bar
33462
- * changing its mind.
33463
- *
33464
- * Worn only while a transition of navi's plays: named the rest of the time, a
33465
- * bar would be captured during every view transition the APPLICATION starts —
33466
- * dead to the pointer and drawn in the top layer for the length of a movement
33467
- * that has nothing to do with it. Being unable to answer a press is the price
33468
- * of being photographed, and a route transition is where it costs nothing:
33469
- * both pages are pictures for those few hundred milliseconds anyway.
33470
- *
33471
- * The WALL of a popup goes the other way round: it is not photographed at
33472
- * all. The top layer is drawn during a transition only as part of the root's
33473
- * picture, which is opted out while an area is marked (route_transition.jsx),
33474
- * and a modal dialog's wall is its ::backdrop — a pseudo-element, which wears
33475
- * no name; a popover's is a real element, but named it would be a picture the
33476
- * size of the screen, sliding across the page arriving. Captured on its own,
33477
- * the popup's box travels; its wall is painted nowhere for the length of the
33478
- * movement, and the page under it leaves undimmed. So the wall is painted
33479
- * INTO the page's picture instead: a stand-in laid over the area before each
33480
- * of the two pictures is taken, painting what the wall paints, and removed
33481
- * with the movement. Carried by the page's picture, it leaves with the page
33482
- * being left and arrives with the page arriving, cut at the page's edge — and
33483
- * under the popup's own picture, which stands over the pages (the z-order in
33484
- * route_transition.jsx). The bars are under the wall as much as the page is,
33485
- * and each is a picture of its own: the same stand-in is laid over every bar
33486
- * outside the area. A bar the two states share is one group with two
33487
- * pictures — dimmed on the side that has a wall — and its cross-fade is the
33488
- * wall fading out as the page leaves, or in as it arrives; a bar only one
33489
- * state has carries the wall with it. What no picture covers — the glass
33490
- * beside a narrowed app, the window below a page shorter than it — shows the
33491
- * live document through, and only the live document can paint a wall there:
33492
- * one fixed stand-in over the window, under the pictures, with a hole cut
33493
- * where each picture stands, its opacity taken from the state being left to
33494
- * the state arriving on the movement's own clock. A popup with layer="local"
33495
- * paints its wall inside the page and needs none of this.
33496
- */
33497
-
33498
33419
  // The browser's top layer: painted above everything the document paints, so
33499
33420
  // outside the area's picture whatever the DOM says.
33500
33421
  const TOP_LAYER_SELECTOR = ":modal, :popover-open";
@@ -33519,6 +33440,11 @@ const FURNITURE_NAME_PREFIX = "navi-transition-furniture-";
33519
33440
  const TOP_LAYER_WALL_SELECTOR =
33520
33441
  ".navi_dialog:modal, .navi_popover_backdrop:popover-open, .navi_popup_group:modal";
33521
33442
  const WALL_ATTRIBUTE = "data-navi-transition-wall";
33443
+ // Worn by a bar dimmed by a filter of navi's; the property holds the whole
33444
+ // chain, the bar's own filter first (see dimBarPicture).
33445
+ const WALL_FILTER_ATTRIBUTE = "data-navi-transition-wall-filter";
33446
+ const WALL_FILTER_PROPERTY = "--navi-transition-wall-filter";
33447
+ const WALL_FILTERS_ATTRIBUTE = "data-navi-transition-wall-filters";
33522
33448
  // Which side of the movement a bar is on, worn by the bar and read by the
33523
33449
  // browser as the class of its group (the CSS below): "leaving" from the first
33524
33450
  // picture, "arriving" for a bar the state arriving brought, "shared" for one
@@ -33574,6 +33500,18 @@ const TRANSITION_FURNITURE_CSS = /* css */ `.navi_fixed_bar[data-navi-transition
33574
33500
  }
33575
33501
  }
33576
33502
 
33503
+ .navi_fixed_bar[data-navi-transition-wall-filter] {
33504
+ filter: var(--navi-transition-wall-filter) !important;
33505
+ }
33506
+
33507
+ [data-navi-transition-wall-filters] {
33508
+ pointer-events: none;
33509
+ width: 0;
33510
+ height: 0;
33511
+ position: fixed;
33512
+ overflow: hidden;
33513
+ }
33514
+
33577
33515
  :root:not(:active-view-transition) [data-navi-transition-wall="rest"] {
33578
33516
  clip-path: var(--wall-holes-arriving, var(--wall-holes));
33579
33517
  }
@@ -33604,9 +33542,13 @@ let namedElements = new Set();
33604
33542
  // The rule giving the one-sided bars their movement, written for one movement
33605
33543
  // and taken down with it.
33606
33544
  let travelStyleElement = null;
33607
- // The stand-ins for the walls open in the top layer, painted for one picture
33608
- // and taken down before the next.
33545
+ // The walls open in the top layer, painted for one picture and taken down
33546
+ // before the next: the area's stand-ins, the bars wearing a filter for them,
33547
+ // and the <svg> holding those filters.
33609
33548
  let wallElements = [];
33549
+ let dimmedBars = [];
33550
+ let wallFilterSvg = null;
33551
+ let wallFilterCount = 0;
33610
33552
  // The stand-ins for what no picture covers, kept for the whole movement, and
33611
33553
  // the opacity they are heading to once it plays.
33612
33554
  let restWallElements = [];
@@ -33801,12 +33743,13 @@ const releaseTransitionFurniture = (owner) => {
33801
33743
  removeRestWalls();
33802
33744
  };
33803
33745
 
33804
- // One stand-in per open wall in every picture, walls in document order: they
33805
- // stack in the top layer, and what dims the document is all of them. A wall
33806
- // open anywhere covers everything the document paints, so the sources are
33807
- // looked for in the whole document — a dialog opened from a bar dims the
33808
- // pages too. A bar inside the area is part of the pages' picture, and the
33809
- // area's stand-in answers for it.
33746
+ // One stand-in per open wall over the pages, and one filter per open wall on
33747
+ // every bar outside them, walls in document order: they stack in the top
33748
+ // layer, and what dims the document is all of them. A wall open anywhere
33749
+ // covers everything the document paints, so the sources are looked for in the
33750
+ // whole document — a dialog opened from a bar dims the pages too. A bar inside
33751
+ // the area is part of the pages' picture, and the area's stand-in answers for
33752
+ // it.
33810
33753
  const paintTransitionWalls = (areaElement) => {
33811
33754
  removeTransitionWalls();
33812
33755
  const sources = Array.from(
@@ -33815,23 +33758,24 @@ const paintTransitionWalls = (areaElement) => {
33815
33758
  if (sources.length === 0) {
33816
33759
  return sources;
33817
33760
  }
33818
- for (const target of pictureTargets(areaElement)) {
33819
- for (const source of sources) {
33820
- const wall = createWall(source);
33821
- target.appendChild(wall);
33822
- // The target is not necessarily a containing block (the area is a plain
33823
- // box), and made one for the movement it would move whatever the page
33824
- // positioned against an ancestor of it: the wall is placed from
33825
- // wherever its containing block turns out to be, by the offset between
33826
- // that box and the target's.
33827
- const targetRect = pictureRect(target);
33828
- const wallRect = wall.getBoundingClientRect();
33829
- wall.style.left = `${targetRect.left - wallRect.left}px`;
33830
- wall.style.top = `${targetRect.top - wallRect.top}px`;
33831
- wall.style.width = `${targetRect.right - targetRect.left}px`;
33832
- wall.style.height = `${targetRect.bottom - targetRect.top}px`;
33833
- wallElements.push(wall);
33834
- }
33761
+ for (const source of sources) {
33762
+ const wall = createWall(source);
33763
+ areaElement.appendChild(wall);
33764
+ // The area is not necessarily a containing block (it is a plain box), and
33765
+ // made one for the movement it would move whatever the page positioned
33766
+ // against an ancestor of it: the wall is placed from wherever its
33767
+ // containing block turns out to be, by the offset between that box and
33768
+ // the area's.
33769
+ const areaRect = areaElement.getBoundingClientRect();
33770
+ const wallRect = wall.getBoundingClientRect();
33771
+ wall.style.left = `${areaRect.left - wallRect.left}px`;
33772
+ wall.style.top = `${areaRect.top - wallRect.top}px`;
33773
+ wall.style.width = `${areaRect.width}px`;
33774
+ wall.style.height = `${areaRect.height}px`;
33775
+ wallElements.push(wall);
33776
+ }
33777
+ for (const bar of barsOutside(areaElement)) {
33778
+ dimBarPicture(bar, sources);
33835
33779
  }
33836
33780
  return sources;
33837
33781
  };
@@ -33841,18 +33785,102 @@ const removeTransitionWalls = () => {
33841
33785
  wall.remove();
33842
33786
  }
33843
33787
  wallElements = [];
33788
+ for (const bar of dimmedBars) {
33789
+ bar.removeAttribute(WALL_FILTER_ATTRIBUTE);
33790
+ bar.style.removeProperty(WALL_FILTER_PROPERTY);
33791
+ }
33792
+ dimmedBars = [];
33793
+ if (wallFilterSvg) {
33794
+ wallFilterSvg.remove();
33795
+ wallFilterSvg = null;
33796
+ }
33844
33797
  };
33845
33798
 
33846
- // What is photographed on its own and gets a stand-in in its picture: the
33799
+ // What is photographed on its own and carries the wall in its picture: the
33847
33800
  // pages, and every bar outside them.
33848
33801
  const pictureTargets = (areaElement) => {
33849
- const targets = [areaElement];
33802
+ return [areaElement, ...barsOutside(areaElement)];
33803
+ };
33804
+
33805
+ const barsOutside = (areaElement) => {
33806
+ const bars = [];
33850
33807
  for (const bar of document.querySelectorAll(FIXED_BAR_SELECTOR$1)) {
33851
33808
  if (!areaElement.contains(bar)) {
33852
- targets.push(bar);
33809
+ bars.push(bar);
33853
33810
  }
33854
33811
  }
33855
- return targets;
33812
+ return bars;
33813
+ };
33814
+
33815
+ // Room around what a bar's picture holds for what paints past every box — a
33816
+ // shadow, the blur of a wall — which no API measures: a filter cuts whatever
33817
+ // falls outside its region.
33818
+ const WALL_FILTER_INK_ROOM = 100;
33819
+ const SVG_NS = "http://www.w3.org/2000/svg";
33820
+
33821
+ // The bar's picture dimmed, not a rectangle over it: each wall's colour is
33822
+ // flooded atop the bar's own pixels (Porter-Duff source-atop, which no blend
33823
+ // mode gives), so what the bar leaves transparent stays so. Composited over
33824
+ // the area's picture and its stand-in, that is the wall over the bar over the
33825
+ // page: the frame at rest. A wall's filter comes before its colour, as its
33826
+ // backdrop-filter does at rest.
33827
+ const dimBarPicture = (bar, sources) => {
33828
+ const box = bar.getBoundingClientRect();
33829
+ // The filter region is in objectBoundingBox units, which measure from the
33830
+ // box: one without an area leaves nothing to measure from.
33831
+ if (box.width === 0 || box.height === 0) {
33832
+ return;
33833
+ }
33834
+ const picture = pictureRect(bar);
33835
+ const region = {
33836
+ x: (picture.left - WALL_FILTER_INK_ROOM - box.left) / box.width,
33837
+ y: (picture.top - WALL_FILTER_INK_ROOM - box.top) / box.height,
33838
+ width:
33839
+ (picture.right - picture.left + 2 * WALL_FILTER_INK_ROOM) / box.width,
33840
+ height:
33841
+ (picture.bottom - picture.top + 2 * WALL_FILTER_INK_ROOM) / box.height,
33842
+ };
33843
+ // Read while the bar wears none of navi's: removeTransitionWalls took it.
33844
+ const ownFilter = getComputedStyle(bar).filter;
33845
+ const chain = ownFilter === "none" ? [] : [ownFilter];
33846
+ for (const source of sources) {
33847
+ const backdropFilter = getComputedStyle(source)
33848
+ .getPropertyValue("--backdrop-filter")
33849
+ .trim();
33850
+ if (backdropFilter && backdropFilter !== "none") {
33851
+ chain.push(backdropFilter);
33852
+ }
33853
+ chain.push(`url(#${createWallFilter(source, region).id})`);
33854
+ }
33855
+ bar.style.setProperty(WALL_FILTER_PROPERTY, chain.join(" "));
33856
+ bar.setAttribute(WALL_FILTER_ATTRIBUTE, "");
33857
+ dimmedBars.push(bar);
33858
+ };
33859
+
33860
+ const createWallFilter = (source, region) => {
33861
+ if (!wallFilterSvg) {
33862
+ wallFilterSvg = document.createElementNS(SVG_NS, "svg");
33863
+ wallFilterSvg.setAttribute(WALL_FILTERS_ATTRIBUTE, "");
33864
+ wallFilterSvg.setAttribute("aria-hidden", "true");
33865
+ document.body.appendChild(wallFilterSvg);
33866
+ }
33867
+ wallFilterCount++;
33868
+ const filter = document.createElementNS(SVG_NS, "filter");
33869
+ filter.id = `navi-transition-wall-${wallFilterCount}`;
33870
+ // linearRGB, the default, floods another colour than the wall's.
33871
+ filter.setAttribute("color-interpolation-filters", "sRGB");
33872
+ filter.setAttribute("x", region.x);
33873
+ filter.setAttribute("y", region.y);
33874
+ filter.setAttribute("width", region.width);
33875
+ filter.setAttribute("height", region.height);
33876
+ const flood = document.createElementNS(SVG_NS, "feFlood");
33877
+ flood.setAttribute("flood-color", readBackdropColor(source));
33878
+ const composite = document.createElementNS(SVG_NS, "feComposite");
33879
+ composite.setAttribute("in2", "SourceGraphic");
33880
+ composite.setAttribute("operator", "atop");
33881
+ filter.append(flood, composite);
33882
+ wallFilterSvg.appendChild(filter);
33883
+ return filter;
33856
33884
  };
33857
33885
 
33858
33886
  const createWall = (source) => {
@@ -33866,8 +33894,8 @@ const createWall = (source) => {
33866
33894
  };
33867
33895
 
33868
33896
  // One per open wall, over the window, at the opacity of the state they are
33869
- // painted from. A hole is cut where a picture stands, since the picture has
33870
- // a stand-in of its own and shows the live document through nowhere — and on
33897
+ // painted from. A hole is cut where a picture stands, since the picture
33898
+ // carries the wall itself and shows the live document through nowhere — and on
33871
33899
  // the frames the live document IS shown, the first and the last, a hole is
33872
33900
  // what keeps the two from being painted on top of each other.
33873
33901
  const paintRestWalls = (sources, opacity) => {
@@ -33888,10 +33916,10 @@ const measurePictureRects = (areaElement) => {
33888
33916
  return rects;
33889
33917
  };
33890
33918
 
33891
- // What the picture holds, which is what the wall covers at rest: a bar's
33892
- // picture carries what its content paints outside its box (a button standing
33893
- // up out of a tab bar), so its rectangle is taken with its descendants'. The
33894
- // pages' is their own box — the movement cuts them at it anyway.
33919
+ // What the picture holds: a bar's picture carries what its content paints
33920
+ // outside its box (a button standing up out of a tab bar), so its rectangle
33921
+ // is taken with its descendants'. The pages' is their own box — the movement
33922
+ // cuts them at it anyway.
33895
33923
  const pictureRect = (target) => {
33896
33924
  const rect = target.getBoundingClientRect();
33897
33925
  let { left, top, right, bottom } = rect;
@@ -33899,9 +33927,6 @@ const pictureRect = (target) => {
33899
33927
  return { left, top, right, bottom };
33900
33928
  }
33901
33929
  for (const descendant of target.querySelectorAll("*")) {
33902
- if (descendant.hasAttribute(WALL_ATTRIBUTE)) {
33903
- continue;
33904
- }
33905
33930
  const descendantRect = descendant.getBoundingClientRect();
33906
33931
  if (descendantRect.width === 0 || descendantRect.height === 0) {
33907
33932
  continue;