astro 3.0.4 → 3.0.6

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.
@@ -98,6 +98,17 @@ const { fallback = 'animate' } = Astro.props as Props;
98
98
  return wait;
99
99
  }
100
100
 
101
+ function isInfinite(animation: Animation) {
102
+ const effect = animation.effect;
103
+ if(
104
+ !effect ||
105
+ !(effect instanceof KeyframeEffect) ||
106
+ !effect.target
107
+ ) return false;
108
+ const style = window.getComputedStyle(effect.target, effect.pseudoElement);
109
+ return style.animationIterationCount === "infinite";
110
+ }
111
+
101
112
  const parser = new DOMParser();
102
113
 
103
114
  async function updateDOM(html: string, state?: State, fallback?: Fallback) {
@@ -221,8 +232,10 @@ const { fallback = 'animate' } = Astro.props as Props;
221
232
 
222
233
  if (fallback === 'animate') {
223
234
  // Trigger the animations
235
+ const currentAnimations = document.getAnimations();
224
236
  document.documentElement.dataset.astroTransitionFallback = 'old';
225
- const finished = Promise.all(document.getAnimations().map(a => a.finished));
237
+ const newAnimations = document.getAnimations().filter(a => !currentAnimations.includes(a) && !isInfinite(a));
238
+ const finished = Promise.all(newAnimations.map(a => a.finished));
226
239
  const fallbackSwap = () => {
227
240
  swap();
228
241
  document.documentElement.dataset.astroTransitionFallback = 'new';
@@ -287,6 +300,7 @@ const { fallback = 'animate' } = Astro.props as Props;
287
300
  !link ||
288
301
  !(link instanceof HTMLAnchorElement) ||
289
302
  link.dataset.astroReload !== undefined ||
303
+ link.hasAttribute('download') ||
290
304
  !link.href ||
291
305
  (link.target && link.target !== '_self') ||
292
306
  link.origin !== location.origin ||
@@ -347,9 +361,18 @@ const { fallback = 'animate' } = Astro.props as Props;
347
361
  // Just ignore stateless entries.
348
362
  // The browser will handle navigation fine without our help
349
363
  if (ev.state === null) {
364
+ if (history.scrollRestoration) {
365
+ history.scrollRestoration = "auto";
366
+ }
350
367
  return;
351
368
  }
352
369
 
370
+ // With the default "auto", the browser will jump to the old scroll position
371
+ // before the ViewTransition is complete.
372
+ if (history.scrollRestoration) {
373
+ history.scrollRestoration = "manual";
374
+ }
375
+
353
376
  const state: State | undefined = history.state;
354
377
  const nextIndex = state?.index ?? currentHistoryIndex + 1;
355
378
  const direction: Direction = nextIndex > currentHistoryIndex ? 'forward' : 'back';
@@ -1,41 +1,93 @@
1
1
  import * as colors from "kleur/colors";
2
+ import { execSync } from "node:child_process";
2
3
  import { arch, platform } from "node:os";
3
- import whichPm from "which-pm";
4
+ import prompts from "prompts";
4
5
  import { resolveConfig } from "../../core/config/index.js";
5
6
  import { ASTRO_VERSION } from "../../core/constants.js";
6
7
  import { flagsToAstroInlineConfig } from "../flags.js";
7
8
  async function printInfo({ flags }) {
9
+ const rows = [
10
+ ["Astro", `v${ASTRO_VERSION}`],
11
+ ["Node", process.version],
12
+ ["System", getSystem()],
13
+ ["Package Manager", getPackageManager()]
14
+ ];
8
15
  const inlineConfig = flagsToAstroInlineConfig(flags);
9
- const packageManager = await whichPm(process.cwd());
10
- let adapter = "Couldn't determine.";
11
- let integrations = [];
12
- const MAX_PADDING = 25;
13
- function printRow(label, value) {
14
- const padding = MAX_PADDING - label.length;
15
- console.log(`${colors.bold(label)}` + " ".repeat(padding) + `${colors.green(value)}`);
16
- }
17
16
  try {
18
17
  const { userConfig } = await resolveConfig(inlineConfig, "info");
19
- if (userConfig.adapter?.name) {
20
- adapter = userConfig.adapter.name;
21
- }
22
- if (userConfig.integrations) {
23
- integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name);
24
- }
25
- } catch (_e) {
18
+ rows.push(["Output", userConfig.output ?? "static"]);
19
+ rows.push(["Adapter", userConfig.adapter?.name ?? "none"]);
20
+ const integrations = (userConfig?.integrations ?? []).filter(Boolean).flat().map((i) => i?.name).filter(Boolean);
21
+ rows.push(["Integrations", integrations.length > 0 ? integrations : "none"]);
22
+ } catch {
23
+ }
24
+ let output = "";
25
+ for (const [label, value] of rows) {
26
+ output += printRow(label, value);
26
27
  }
28
+ await copyToClipboard(output.trim());
29
+ }
30
+ const SUPPORTED_SYSTEM = /* @__PURE__ */ new Set(["darwin", "win32"]);
31
+ async function copyToClipboard(text) {
32
+ const system = platform();
33
+ if (!SUPPORTED_SYSTEM.has(system))
34
+ return;
27
35
  console.log();
28
- const packageManagerName = packageManager?.name ?? "Couldn't determine.";
29
- printRow("Astro version", `v${ASTRO_VERSION}`);
30
- printRow("Package manager", packageManagerName);
31
- printRow("Platform", platform());
32
- printRow("Architecture", arch());
33
- printRow("Adapter", adapter);
34
- let integrationsString = "None or couldn't determine.";
35
- if (integrations.length > 0) {
36
- integrationsString = integrations.join(", ");
36
+ const { shouldCopy } = await prompts({
37
+ type: "confirm",
38
+ name: "shouldCopy",
39
+ message: "Copy to clipboard?",
40
+ initial: true
41
+ });
42
+ if (!shouldCopy)
43
+ return;
44
+ const command = system === "darwin" ? "pbcopy" : "clip";
45
+ try {
46
+ execSync(`echo ${JSON.stringify(text.trim())} | ${command}`, {
47
+ encoding: "utf8",
48
+ stdio: "ignore"
49
+ });
50
+ } catch (e) {
51
+ console.error(
52
+ colors.red(`
53
+ Sorry, something went wrong!`) + ` Please copy the text above manually.`
54
+ );
55
+ }
56
+ }
57
+ const PLATFORM_TO_OS = {
58
+ darwin: "macOS",
59
+ win32: "Windows",
60
+ linux: "Linux"
61
+ };
62
+ function getSystem() {
63
+ const system = PLATFORM_TO_OS[platform()] ?? platform();
64
+ return `${system} (${arch()})`;
65
+ }
66
+ function getPackageManager() {
67
+ if (!process.env.npm_config_user_agent) {
68
+ return "unknown";
69
+ }
70
+ const specifier = process.env.npm_config_user_agent.split(" ")[0];
71
+ const name = specifier.substring(0, specifier.lastIndexOf("/"));
72
+ return name === "npminstall" ? "cnpm" : name;
73
+ }
74
+ const MAX_PADDING = 25;
75
+ function printRow(label, value) {
76
+ const padding = MAX_PADDING - label.length;
77
+ const [first, ...rest] = Array.isArray(value) ? value : [value];
78
+ let plaintext = `${label}${" ".repeat(padding)}${first}`;
79
+ let richtext = `${colors.bold(label)}${" ".repeat(padding)}${colors.green(first)}`;
80
+ if (rest.length > 0) {
81
+ for (const entry of rest) {
82
+ plaintext += `
83
+ ${" ".repeat(MAX_PADDING)}${entry}`;
84
+ richtext += `
85
+ ${" ".repeat(MAX_PADDING)}${colors.green(entry)}`;
86
+ }
37
87
  }
38
- printRow("Integrations", integrationsString);
88
+ plaintext += "\n";
89
+ console.log(richtext);
90
+ return plaintext;
39
91
  }
40
92
  export {
41
93
  printInfo
@@ -111,7 +111,10 @@ function vitePluginSSRSplit(internals, adapter, options) {
111
111
  options(opts) {
112
112
  if (options.settings.config.build.split || functionPerRouteEnabled) {
113
113
  const inputs = /* @__PURE__ */ new Set();
114
- for (const path of Object.keys(options.allPages)) {
114
+ for (const [path, pageData] of Object.entries(options.allPages)) {
115
+ if (routeIsRedirect(pageData.route)) {
116
+ continue;
117
+ }
115
118
  inputs.add(getVirtualModulePageNameFromPath(SPLIT_MODULE_ID, path));
116
119
  }
117
120
  return addRollupInput(opts, Array.from(inputs));
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "3.0.4";
1
+ const ASTRO_VERSION = "3.0.6";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -20,7 +20,7 @@ async function dev(inlineConfig) {
20
20
  base: restart.container.settings.config.base
21
21
  })
22
22
  );
23
- const currentVersion = "3.0.4";
23
+ const currentVersion = "3.0.6";
24
24
  if (currentVersion.includes("-")) {
25
25
  logger.warn(null, msg.prerelease({ currentVersion }));
26
26
  }
@@ -50,7 +50,7 @@ function serverStart({
50
50
  base,
51
51
  isRestart = false
52
52
  }) {
53
- const version = "3.0.4";
53
+ const version = "3.0.6";
54
54
  const localPrefix = `${dim("\u2503")} Local `;
55
55
  const networkPrefix = `${dim("\u2503")} Network `;
56
56
  const emptyPrefix = " ".repeat(11);
@@ -235,7 +235,7 @@ function printHelp({
235
235
  message.push(
236
236
  linebreak(),
237
237
  ` ${bgGreen(black(` ${commandName} `))} ${green(
238
- `v${"3.0.4"}`
238
+ `v${"3.0.6"}`
239
239
  )} ${headline}`
240
240
  );
241
241
  }
@@ -1,3 +1,4 @@
1
+ import { trimSlashes } from "../path.js";
1
2
  import { validateGetStaticPathsParameter } from "./validation.js";
2
3
  function getParams(array) {
3
4
  const fn = (match) => {
@@ -17,7 +18,9 @@ function stringifyParams(params, route) {
17
18
  const validatedParams = Object.entries(params).reduce((acc, next) => {
18
19
  validateGetStaticPathsParameter(next, route.component);
19
20
  const [key, value] = next;
20
- acc[key] = value?.toString();
21
+ if (value !== void 0) {
22
+ acc[key] = typeof value === "string" ? trimSlashes(value) : value.toString();
23
+ }
21
24
  return acc;
22
25
  }, {});
23
26
  return JSON.stringify(route.generate(validatedParams));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "3.0.4",
3
+ "version": "3.0.6",
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",