astro 3.4.0 → 3.4.2

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.
@@ -7,7 +7,13 @@ var xray_default = {
7
7
  init(canvas) {
8
8
  let islandsOverlays = [];
9
9
  addIslandsOverlay();
10
+ document.addEventListener("astro:after-swap", addIslandsOverlay);
11
+ document.addEventListener("astro:page-load", refreshIslandsOverlayPositions);
10
12
  function addIslandsOverlay() {
13
+ islandsOverlays.forEach(({ highlightElement }) => {
14
+ highlightElement.remove();
15
+ });
16
+ islandsOverlays = [];
11
17
  const islands = document.querySelectorAll("astro-island");
12
18
  islands.forEach((island) => {
13
19
  const computedStyle = window.getComputedStyle(island);
@@ -23,16 +29,17 @@ var xray_default = {
23
29
  islandsOverlays.push({ highlightElement: highlight, island: islandElement });
24
30
  });
25
31
  ["scroll", "resize"].forEach((event) => {
26
- window.addEventListener(event, () => {
27
- islandsOverlays.forEach(({ highlightElement, island: islandElement }) => {
28
- const newRect = islandElement.getBoundingClientRect();
29
- positionHighlight(highlightElement, newRect);
30
- });
31
- });
32
+ window.addEventListener(event, refreshIslandsOverlayPositions);
33
+ });
34
+ }
35
+ function refreshIslandsOverlayPositions() {
36
+ islandsOverlays.forEach(({ highlightElement, island: islandElement }) => {
37
+ const rect = islandElement.getBoundingClientRect();
38
+ positionHighlight(highlightElement, rect);
32
39
  });
33
40
  }
34
41
  function buildIslandTooltip(island) {
35
- const tooltip = document.createElement("astro-overlay-tooltip");
42
+ const tooltip = document.createElement("astro-dev-overlay-tooltip");
36
43
  tooltip.sections = [];
37
44
  const islandProps = island.getAttribute("props") ? JSON.parse(island.getAttribute("props")) : {};
38
45
  const islandClientDirective = island.getAttribute("client");
@@ -45,6 +45,11 @@ class DevOverlayTooltip extends HTMLElement {
45
45
  padding: 8px;
46
46
  }
47
47
 
48
+ .section-content {
49
+ max-height: 250px;
50
+ overflow-y: auto;
51
+ }
52
+
48
53
  .modal-title {
49
54
  display: flex;
50
55
  justify-content: space-between;
@@ -103,7 +108,7 @@ class DevOverlayTooltip extends HTMLElement {
103
108
  sectionElement.innerHTML = `
104
109
  ${section.title ? `<div class="modal-title"><span class="modal-main-title">
105
110
  ${section.icon ? this.getElementForIcon(section.icon) : ""}${section.title}</span>${section.inlineTitle ?? ""}</div>` : ""}
106
- ${section.content ? `<div>${section.content}</div>` : ""}
111
+ ${section.content ? `<div class="section-content">${section.content}</div>` : ""}
107
112
  ${section.clickDescription ? `<span class="modal-cta">${section.clickDescription}</span>` : ""}
108
113
  `;
109
114
  fragment.append(sectionElement);
@@ -24,7 +24,7 @@ class DevOverlayWindow extends HTMLElement {
24
24
  font-family: ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
25
25
  color: rgba(204, 206, 216, 1);
26
26
  position: fixed;
27
- z-index: 9999999999;
27
+ z-index: 999999999;
28
28
  top: 55%;
29
29
  left: 50%;
30
30
  transform: translate(-50%, -50%);
@@ -16,8 +16,15 @@ class AstroComponentInstance {
16
16
  this.factory = factory;
17
17
  this.slotValues = {};
18
18
  for (const name in slots) {
19
- const value = slots[name](result);
20
- this.slotValues[name] = () => value;
19
+ let didRender = false;
20
+ let value = slots[name](result);
21
+ this.slotValues[name] = () => {
22
+ if (!didRender) {
23
+ didRender = true;
24
+ return value;
25
+ }
26
+ return slots[name](result);
27
+ };
21
28
  }
22
29
  }
23
30
  async init(result) {
@@ -9,10 +9,7 @@ const announce = () => {
9
9
  let div = document.createElement("div");
10
10
  div.setAttribute("aria-live", "assertive");
11
11
  div.setAttribute("aria-atomic", "true");
12
- div.setAttribute(
13
- "style",
14
- "position:absolute;left:0;top:0;clip:rect(0 0 0 0);clip-path:inset(50%);overflow:hidden;white-space:nowrap;width:1px;height:1px"
15
- );
12
+ div.className = "astro-route-announcer";
16
13
  document.body.append(div);
17
14
  setTimeout(
18
15
  () => {
@@ -362,9 +359,14 @@ if (inBrowser) {
362
359
  async function prepareForClientOnlyComponents(newDocument, toLocation) {
363
360
  if (newDocument.body.querySelector(`astro-island[client='only']`)) {
364
361
  const nextPage = document.createElement("iframe");
365
- nextPage.setAttribute("src", toLocation.href);
362
+ nextPage.srcdoc = (newDocument.doctype ? "<!DOCTYPE html>" : "") + newDocument.documentElement.outerHTML;
366
363
  nextPage.style.display = "none";
367
364
  document.body.append(nextPage);
365
+ nextPage.contentWindow.console = Object.keys(console).reduce((acc, key) => {
366
+ acc[key] = () => {
367
+ };
368
+ return acc;
369
+ }, {});
368
370
  await hydrationDone(nextPage);
369
371
  const nextHead = nextPage.contentDocument?.head;
370
372
  if (nextHead) {
@@ -375,7 +377,7 @@ async function prepareForClientOnlyComponents(newDocument, toLocation) {
375
377
  viteIds.forEach((id) => {
376
378
  const style = document.head.querySelector(`style[${VITE_ID}="${id}"]`);
377
379
  if (style && !newDocument.head.querySelector(`style[${VITE_ID}="${id}"]`)) {
378
- newDocument.head.appendChild(style);
380
+ newDocument.head.appendChild(style.cloneNode(true));
379
381
  }
380
382
  });
381
383
  }
@@ -204,7 +204,7 @@ async function getScriptsAndStyles({ pipeline, filePath }) {
204
204
  scripts.add({
205
205
  props: {
206
206
  type: "module",
207
- src: await resolveIdToUrl(moduleLoader, "astro/runtime/client/dev-overlay/overlay.js")
207
+ src: await resolveIdToUrl(moduleLoader, "astro/runtime/client/dev-overlay/entrypoint.js")
208
208
  },
209
209
  children: ""
210
210
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "3.4.0",
3
+ "version": "3.4.2",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -138,6 +138,7 @@
138
138
  "js-yaml": "^4.1.0",
139
139
  "kleur": "^4.1.4",
140
140
  "magic-string": "^0.30.3",
141
+ "mdast-util-to-hast": "12.3.0",
141
142
  "mime": "^3.0.0",
142
143
  "ora": "^7.0.1",
143
144
  "p-limit": "^4.0.0",
@@ -160,7 +161,7 @@
160
161
  "vitefu": "^0.2.4",
161
162
  "which-pm": "^2.1.1",
162
163
  "yargs-parser": "^21.1.1",
163
- "zod": "3.21.1",
164
+ "zod": "^3.22.4",
164
165
  "@astrojs/internal-helpers": "0.2.1",
165
166
  "@astrojs/markdown-remark": "3.3.0",
166
167
  "@astrojs/telemetry": "3.0.4"