astro 3.4.4 → 3.5.1

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 (143) hide show
  1. package/client.d.ts +86 -0
  2. package/components/Code.astro +15 -2
  3. package/components/Picture.astro +2 -1
  4. package/components/ViewTransitions.astro +39 -38
  5. package/content-module.template.mjs +4 -14
  6. package/dist/@types/astro.d.ts +227 -5
  7. package/dist/assets/build/generate.d.ts +2 -1
  8. package/dist/assets/build/generate.js +16 -5
  9. package/dist/assets/consts.d.ts +1 -0
  10. package/dist/assets/consts.js +2 -0
  11. package/dist/assets/endpoint/generic.js +6 -2
  12. package/dist/assets/internal.js +9 -2
  13. package/dist/assets/services/service.d.ts +8 -3
  14. package/dist/assets/services/service.js +2 -1
  15. package/dist/assets/services/vendor/squoosh/image-pool.d.ts +1 -2
  16. package/dist/assets/types.d.ts +9 -5
  17. package/dist/assets/utils/emitAsset.js +5 -0
  18. package/dist/assets/utils/metadata.d.ts +1 -2
  19. package/dist/assets/utils/proxy.d.ts +1 -0
  20. package/dist/assets/utils/proxy.js +16 -0
  21. package/dist/assets/utils/queryParams.d.ts +1 -1
  22. package/dist/assets/utils/transformToPath.d.ts +1 -1
  23. package/dist/assets/utils/transformToPath.js +8 -3
  24. package/dist/assets/vite-plugin-assets.js +33 -12
  25. package/dist/cli/build/index.js +1 -1
  26. package/dist/cli/info/index.js +7 -3
  27. package/dist/content/consts.d.ts +1 -0
  28. package/dist/content/consts.js +2 -0
  29. package/dist/content/runtime-assets.d.ts +9 -1
  30. package/dist/content/runtime-assets.js +1 -1
  31. package/dist/content/runtime.d.ts +1 -0
  32. package/dist/content/runtime.js +8 -2
  33. package/dist/content/utils.d.ts +1 -0
  34. package/dist/content/utils.js +9 -0
  35. package/dist/content/vite-plugin-content-assets.js +49 -23
  36. package/dist/content/vite-plugin-content-imports.js +9 -3
  37. package/dist/content/vite-plugin-content-virtual-mod.d.ts +17 -12
  38. package/dist/content/vite-plugin-content-virtual-mod.js +136 -57
  39. package/dist/core/app/index.js +19 -4
  40. package/dist/core/app/types.d.ts +7 -1
  41. package/dist/core/build/buildPipeline.js +17 -4
  42. package/dist/core/build/common.js +2 -0
  43. package/dist/core/build/generate.js +64 -34
  44. package/dist/core/build/index.d.ts +0 -8
  45. package/dist/core/build/index.js +9 -2
  46. package/dist/core/build/internal.d.ts +11 -1
  47. package/dist/core/build/internal.js +23 -1
  48. package/dist/core/build/page-data.js +46 -18
  49. package/dist/core/build/plugin.d.ts +12 -10
  50. package/dist/core/build/plugin.js +14 -22
  51. package/dist/core/build/plugins/index.js +4 -0
  52. package/dist/core/build/plugins/plugin-alias-resolve.js +1 -1
  53. package/dist/core/build/plugins/plugin-analyzer.js +1 -1
  54. package/dist/core/build/plugins/plugin-chunks.d.ts +4 -0
  55. package/dist/core/build/plugins/plugin-chunks.js +31 -0
  56. package/dist/core/build/plugins/plugin-component-entry.js +1 -1
  57. package/dist/core/build/plugins/plugin-content.d.ts +4 -0
  58. package/dist/core/build/plugins/plugin-content.js +273 -0
  59. package/dist/core/build/plugins/plugin-css.js +9 -4
  60. package/dist/core/build/plugins/plugin-hoisted-scripts.js +1 -1
  61. package/dist/core/build/plugins/plugin-internals.js +1 -1
  62. package/dist/core/build/plugins/plugin-manifest.js +14 -5
  63. package/dist/core/build/plugins/plugin-middleware.d.ts +1 -3
  64. package/dist/core/build/plugins/plugin-middleware.js +5 -57
  65. package/dist/core/build/plugins/plugin-pages.js +3 -3
  66. package/dist/core/build/plugins/plugin-prerender.js +2 -5
  67. package/dist/core/build/plugins/plugin-renderers.js +1 -1
  68. package/dist/core/build/plugins/plugin-ssr.js +6 -5
  69. package/dist/core/build/plugins/util.d.ts +3 -3
  70. package/dist/core/build/static-build.d.ts +2 -1
  71. package/dist/core/build/static-build.js +52 -28
  72. package/dist/core/build/types.d.ts +1 -1
  73. package/dist/core/build/util.d.ts +7 -0
  74. package/dist/core/build/util.js +37 -1
  75. package/dist/core/compile/compile.js +1 -0
  76. package/dist/core/config/config.js +3 -0
  77. package/dist/core/config/schema.d.ts +208 -0
  78. package/dist/core/config/schema.js +55 -2
  79. package/dist/core/config/settings.js +1 -0
  80. package/dist/core/constants.js +1 -1
  81. package/dist/core/create-vite.js +9 -3
  82. package/dist/core/dev/dev.js +1 -1
  83. package/dist/core/endpoint/index.d.ts +4 -3
  84. package/dist/core/endpoint/index.js +29 -3
  85. package/dist/core/errors/errors-data.d.ts +11 -0
  86. package/dist/core/errors/errors-data.js +17 -0
  87. package/dist/core/logger/node.js +1 -0
  88. package/dist/core/messages.js +2 -2
  89. package/dist/core/middleware/index.d.ts +7 -3
  90. package/dist/core/middleware/index.js +3 -2
  91. package/dist/core/middleware/loadMiddleware.d.ts +1 -2
  92. package/dist/core/middleware/loadMiddleware.js +3 -4
  93. package/dist/core/middleware/sequence.d.ts +2 -2
  94. package/dist/core/middleware/sequence.js +3 -2
  95. package/dist/core/middleware/vite-plugin.d.ts +9 -0
  96. package/dist/core/middleware/vite-plugin.js +101 -0
  97. package/dist/core/pipeline.d.ts +1 -1
  98. package/dist/core/pipeline.js +6 -4
  99. package/dist/core/redirects/helpers.d.ts +1 -0
  100. package/dist/core/redirects/helpers.js +4 -0
  101. package/dist/core/render/context.d.ts +24 -1
  102. package/dist/core/render/context.js +96 -2
  103. package/dist/core/render/core.d.ts +2 -14
  104. package/dist/core/render/core.js +12 -52
  105. package/dist/core/render/index.d.ts +2 -3
  106. package/dist/core/render/index.js +3 -4
  107. package/dist/core/render/params-and-props.d.ts +1 -1
  108. package/dist/core/render/params-and-props.js +5 -2
  109. package/dist/core/render/result.d.ts +1 -0
  110. package/dist/core/render/result.js +23 -0
  111. package/dist/core/render/route-cache.d.ts +1 -1
  112. package/dist/core/render/route-cache.js +6 -2
  113. package/dist/core/routing/manifest/create.js +117 -4
  114. package/dist/core/sync/index.d.ts +2 -24
  115. package/dist/i18n/index.d.ts +54 -0
  116. package/dist/i18n/index.js +91 -0
  117. package/dist/i18n/middleware.d.ts +2 -0
  118. package/dist/i18n/middleware.js +62 -0
  119. package/dist/i18n/vite-plugin-i18n.d.ts +7 -0
  120. package/dist/i18n/vite-plugin-i18n.js +62 -0
  121. package/dist/integrations/astroFeaturesValidation.js +4 -1
  122. package/dist/integrations/index.js +12 -0
  123. package/dist/prefetch/index.d.ts +31 -0
  124. package/dist/prefetch/index.js +176 -0
  125. package/dist/prefetch/vite-plugin-prefetch.d.ts +5 -0
  126. package/dist/prefetch/vite-plugin-prefetch.js +43 -0
  127. package/dist/runtime/client/dev-overlay/plugins/audit.js +17 -9
  128. package/dist/runtime/server/index.d.ts +0 -2
  129. package/dist/runtime/server/render/component.js +3 -5
  130. package/dist/transitions/router.d.ts +1 -0
  131. package/dist/transitions/router.js +9 -4
  132. package/dist/transitions/vite-plugin-transitions.d.ts +4 -1
  133. package/dist/transitions/vite-plugin-transitions.js +7 -1
  134. package/dist/vite-plugin-astro-server/devPipeline.d.ts +1 -0
  135. package/dist/vite-plugin-astro-server/devPipeline.js +2 -0
  136. package/dist/vite-plugin-astro-server/plugin.js +11 -1
  137. package/dist/vite-plugin-astro-server/route.js +113 -51
  138. package/dist/vite-plugin-head/index.js +1 -1
  139. package/dist/vite-plugin-markdown/index.js +1 -0
  140. package/package.json +8 -6
  141. package/tsconfigs/base.json +1 -1
  142. package/dist/core/endpoint/dev/index.d.ts +0 -2
  143. package/dist/core/endpoint/dev/index.js +0 -17
@@ -0,0 +1,62 @@
1
+ import * as vite from "vite";
2
+ const virtualModuleId = "astro:i18n";
3
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
4
+ function astroInternationalization({
5
+ settings
6
+ }) {
7
+ return {
8
+ name: "astro:i18n",
9
+ enforce: "pre",
10
+ async resolveId(id) {
11
+ if (id === virtualModuleId) {
12
+ return resolvedVirtualModuleId;
13
+ }
14
+ },
15
+ load(id) {
16
+ if (id === resolvedVirtualModuleId) {
17
+ return `
18
+ import {
19
+ getLocaleRelativeUrl as _getLocaleRelativeUrl,
20
+ getLocaleRelativeUrlList as _getLocaleRelativeUrlList,
21
+ getLocaleAbsoluteUrl as _getLocaleAbsoluteUrl,
22
+ getLocaleAbsoluteUrlList as _getLocaleAbsoluteUrlList,
23
+
24
+ } from "astro/i18n";
25
+
26
+ const base = ${JSON.stringify(settings.config.base)};
27
+ const trailingSlash = ${JSON.stringify(settings.config.trailingSlash)};
28
+ const format = ${JSON.stringify(settings.config.build.format)};
29
+ const site = ${JSON.stringify(settings.config.site)};
30
+ const i18n = ${JSON.stringify(settings.config.experimental.i18n)};
31
+
32
+ export const getRelativeLocaleUrl = (locale, path = "", opts) => _getLocaleRelativeUrl({
33
+ locale,
34
+ path,
35
+ base,
36
+ trailingSlash,
37
+ format,
38
+ ...i18n,
39
+ ...opts
40
+ });
41
+ export const getAbsoluteLocaleUrl = (locale, path = "", opts) => _getLocaleAbsoluteUrl({
42
+ locale,
43
+ path,
44
+ base,
45
+ trailingSlash,
46
+ format,
47
+ site,
48
+ ...i18n,
49
+ ...opts
50
+ });
51
+
52
+ export const getRelativeLocaleUrlList = (path = "", opts) => _getLocaleRelativeUrlList({
53
+ base, path, trailingSlash, format, ...i18n, ...opts });
54
+ export const getAbsoluteLocaleUrlList = (path = "", opts) => _getLocaleAbsoluteUrlList({ base, path, trailingSlash, format, site, ...i18n, ...opts });
55
+ `;
56
+ }
57
+ }
58
+ };
59
+ }
60
+ export {
61
+ astroInternationalization as default
62
+ };
@@ -11,7 +11,10 @@ const ALL_UNSUPPORTED = {
11
11
  serverOutput: UNSUPPORTED,
12
12
  staticOutput: UNSUPPORTED,
13
13
  hybridOutput: UNSUPPORTED,
14
- assets: UNSUPPORTED_ASSETS_FEATURE
14
+ assets: UNSUPPORTED_ASSETS_FEATURE,
15
+ i18n: {
16
+ detectBrowserLanguage: UNSUPPORTED
17
+ }
15
18
  };
16
19
  function validateSupportedFeatures(adapterName, featureMap = ALL_UNSUPPORTED, config, logger) {
17
20
  const {
@@ -94,6 +94,18 @@ async function runHookConfigSetup({
94
94
  }
95
95
  addedClientDirectives.set(name, buildClientDirectiveEntrypoint(name, entrypoint));
96
96
  },
97
+ addMiddleware: ({ order, entrypoint }) => {
98
+ if (typeof updatedSettings.middlewares[order] === "undefined") {
99
+ throw new Error(
100
+ `The "${integration.name}" integration is trying to add middleware but did not specify an order.`
101
+ );
102
+ }
103
+ logger.debug(
104
+ "middleware",
105
+ `The integration ${integration.name} has added middleware that runs ${order === "pre" ? "before" : "after"} any application middleware you define.`
106
+ );
107
+ updatedSettings.middlewares[order].push(entrypoint);
108
+ },
97
109
  logger: integrationLogger
98
110
  };
99
111
  Object.defineProperty(hooks, "addPageExtension", {
@@ -0,0 +1,31 @@
1
+ interface InitOptions {
2
+ defaultStrategy?: string;
3
+ prefetchAll?: boolean;
4
+ }
5
+ /**
6
+ * Initialize the prefetch script, only works once.
7
+ *
8
+ * @param defaultOpts Default options for prefetching if not already set by the user config.
9
+ */
10
+ export declare function init(defaultOpts?: InitOptions): void;
11
+ export interface PrefetchOptions {
12
+ /**
13
+ * How the prefetch should prioritize the URL. (default `'link'`)
14
+ * - `'link'`: use `<link rel="prefetch">`, has lower loading priority.
15
+ * - `'fetch'`: use `fetch()`, has higher loading priority.
16
+ */
17
+ with?: 'link' | 'fetch';
18
+ }
19
+ /**
20
+ * Prefetch a URL so it's cached when the user navigates to it.
21
+ *
22
+ * @param url A full or partial URL string based on the current `location.href`. They are only fetched if:
23
+ * - The user is online
24
+ * - The user is not in data saver mode
25
+ * - The URL is within the same origin
26
+ * - The URL is not the current page
27
+ * - The URL has not already been prefetched
28
+ * @param opts Additional options for prefetching.
29
+ */
30
+ export declare function prefetch(url: string, opts?: PrefetchOptions): void;
31
+ export {};
@@ -0,0 +1,176 @@
1
+ const debug = import.meta.env.DEV ? console.debug : void 0;
2
+ const inBrowser = import.meta.env.SSR === false;
3
+ const prefetchedUrls = /* @__PURE__ */ new Set();
4
+ const listenedAnchors = /* @__PURE__ */ new WeakSet();
5
+ let prefetchAll = __PREFETCH_PREFETCH_ALL__;
6
+ let defaultStrategy = __PREFETCH_DEFAULT_STRATEGY__;
7
+ let inited = false;
8
+ function init(defaultOpts) {
9
+ if (!inBrowser)
10
+ return;
11
+ if (inited)
12
+ return;
13
+ inited = true;
14
+ debug?.(`[astro] Initializing prefetch script`);
15
+ prefetchAll ??= defaultOpts?.prefetchAll ?? false;
16
+ defaultStrategy ??= defaultOpts?.defaultStrategy ?? "hover";
17
+ initTapStrategy();
18
+ initHoverStrategy();
19
+ initViewportStrategy();
20
+ }
21
+ function initTapStrategy() {
22
+ for (const event of ["touchstart", "mousedown"]) {
23
+ document.body.addEventListener(
24
+ event,
25
+ (e) => {
26
+ if (elMatchesStrategy(e.target, "tap")) {
27
+ prefetch(e.target.href, { with: "fetch" });
28
+ }
29
+ },
30
+ { passive: true }
31
+ );
32
+ }
33
+ }
34
+ function initHoverStrategy() {
35
+ let timeout;
36
+ document.body.addEventListener(
37
+ "focusin",
38
+ (e) => {
39
+ if (elMatchesStrategy(e.target, "hover")) {
40
+ handleHoverIn(e);
41
+ }
42
+ },
43
+ { passive: true }
44
+ );
45
+ document.body.addEventListener("focusout", handleHoverOut, { passive: true });
46
+ onPageLoad(() => {
47
+ for (const anchor of document.getElementsByTagName("a")) {
48
+ if (listenedAnchors.has(anchor))
49
+ continue;
50
+ if (elMatchesStrategy(anchor, "hover")) {
51
+ listenedAnchors.add(anchor);
52
+ anchor.addEventListener("mouseenter", handleHoverIn, { passive: true });
53
+ anchor.addEventListener("mouseleave", handleHoverOut, { passive: true });
54
+ }
55
+ }
56
+ });
57
+ function handleHoverIn(e) {
58
+ const href = e.target.href;
59
+ if (timeout) {
60
+ clearTimeout(timeout);
61
+ }
62
+ timeout = setTimeout(() => {
63
+ prefetch(href, { with: "fetch" });
64
+ }, 80);
65
+ }
66
+ function handleHoverOut() {
67
+ if (timeout) {
68
+ clearTimeout(timeout);
69
+ timeout = 0;
70
+ }
71
+ }
72
+ }
73
+ function initViewportStrategy() {
74
+ let observer;
75
+ onPageLoad(() => {
76
+ for (const anchor of document.getElementsByTagName("a")) {
77
+ if (listenedAnchors.has(anchor))
78
+ continue;
79
+ if (elMatchesStrategy(anchor, "viewport")) {
80
+ listenedAnchors.add(anchor);
81
+ observer ??= createViewportIntersectionObserver();
82
+ observer.observe(anchor);
83
+ }
84
+ }
85
+ });
86
+ }
87
+ function createViewportIntersectionObserver() {
88
+ const timeouts = /* @__PURE__ */ new WeakMap();
89
+ return new IntersectionObserver((entries, observer) => {
90
+ for (const entry of entries) {
91
+ const anchor = entry.target;
92
+ const timeout = timeouts.get(anchor);
93
+ if (entry.isIntersecting) {
94
+ if (timeout) {
95
+ clearTimeout(timeout);
96
+ }
97
+ timeouts.set(
98
+ anchor,
99
+ setTimeout(() => {
100
+ observer.unobserve(anchor);
101
+ timeouts.delete(anchor);
102
+ prefetch(anchor.href, { with: "link" });
103
+ }, 300)
104
+ );
105
+ } else {
106
+ if (timeout) {
107
+ clearTimeout(timeout);
108
+ timeouts.delete(anchor);
109
+ }
110
+ }
111
+ }
112
+ });
113
+ }
114
+ function prefetch(url, opts) {
115
+ if (!canPrefetchUrl(url))
116
+ return;
117
+ prefetchedUrls.add(url);
118
+ const priority = opts?.with ?? "link";
119
+ debug?.(`[astro] Prefetching ${url} with ${priority}`);
120
+ if (priority === "link") {
121
+ const link = document.createElement("link");
122
+ link.rel = "prefetch";
123
+ link.setAttribute("href", url);
124
+ document.head.append(link);
125
+ } else {
126
+ fetch(url).catch((e) => {
127
+ console.log(`[astro] Failed to prefetch ${url}`);
128
+ console.error(e);
129
+ });
130
+ }
131
+ }
132
+ function canPrefetchUrl(url) {
133
+ if (!navigator.onLine)
134
+ return false;
135
+ if ("connection" in navigator) {
136
+ const conn = navigator.connection;
137
+ if (conn.saveData || /(2|3)g/.test(conn.effectiveType))
138
+ return false;
139
+ }
140
+ try {
141
+ const urlObj = new URL(url, location.href);
142
+ return location.origin === urlObj.origin && location.pathname !== urlObj.pathname && !prefetchedUrls.has(url);
143
+ } catch {
144
+ }
145
+ return false;
146
+ }
147
+ function elMatchesStrategy(el, strategy) {
148
+ if (el?.tagName !== "A")
149
+ return false;
150
+ const attrValue = el.dataset.astroPrefetch;
151
+ if (attrValue === "false") {
152
+ return false;
153
+ }
154
+ if (attrValue == null && prefetchAll || attrValue === "") {
155
+ return strategy === defaultStrategy;
156
+ }
157
+ if (attrValue === strategy) {
158
+ return true;
159
+ }
160
+ return false;
161
+ }
162
+ function onPageLoad(cb) {
163
+ cb();
164
+ let firstLoad = false;
165
+ document.addEventListener("astro:page-load", () => {
166
+ if (!firstLoad) {
167
+ firstLoad = true;
168
+ return;
169
+ }
170
+ cb();
171
+ });
172
+ }
173
+ export {
174
+ init,
175
+ prefetch
176
+ };
@@ -0,0 +1,5 @@
1
+ import * as vite from 'vite';
2
+ import type { AstroSettings } from '../@types/astro.js';
3
+ export default function astroPrefetch({ settings }: {
4
+ settings: AstroSettings;
5
+ }): vite.Plugin;
@@ -0,0 +1,43 @@
1
+ import * as vite from "vite";
2
+ const virtualModuleId = "astro:prefetch";
3
+ const resolvedVirtualModuleId = "\0" + virtualModuleId;
4
+ const prefetchInternalModuleFsSubpath = "astro/dist/prefetch/index.js";
5
+ const prefetchCode = `import { init } from 'astro/prefetch';init()`;
6
+ function astroPrefetch({ settings }) {
7
+ const prefetchOption = settings.config.prefetch;
8
+ const prefetch = prefetchOption ? typeof prefetchOption === "object" ? prefetchOption : {} : void 0;
9
+ if (prefetch && settings.scripts.every((s) => s.content !== prefetchCode)) {
10
+ settings.scripts.push({
11
+ stage: "page",
12
+ content: `import { init } from 'astro/prefetch';init()`
13
+ });
14
+ }
15
+ const throwPrefetchNotEnabledError = () => {
16
+ throw new Error("You need to enable the `prefetch` Astro config to import `astro:prefetch`");
17
+ };
18
+ return {
19
+ name: "astro:prefetch",
20
+ async resolveId(id) {
21
+ if (id === virtualModuleId) {
22
+ if (!prefetch)
23
+ throwPrefetchNotEnabledError();
24
+ return resolvedVirtualModuleId;
25
+ }
26
+ },
27
+ load(id) {
28
+ if (id === resolvedVirtualModuleId) {
29
+ if (!prefetch)
30
+ throwPrefetchNotEnabledError();
31
+ return `export { prefetch } from "astro/prefetch";`;
32
+ }
33
+ },
34
+ transform(code, id) {
35
+ if (id.includes(prefetchInternalModuleFsSubpath)) {
36
+ return code.replace("__PREFETCH_PREFETCH_ALL__", JSON.stringify(prefetch?.prefetchAll)).replace("__PREFETCH_DEFAULT_STRATEGY__", JSON.stringify(prefetch?.defaultStrategy));
37
+ }
38
+ }
39
+ };
40
+ }
41
+ export {
42
+ astroPrefetch as default
43
+ };
@@ -84,12 +84,12 @@ var audit_default = {
84
84
  }
85
85
  const rect = originalElement.getBoundingClientRect();
86
86
  const highlight = createHighlight(rect, "warning");
87
- const tooltip = buildAuditTooltip(rule);
87
+ const tooltip = buildAuditTooltip(rule, originalElement);
88
88
  attachTooltipToHighlight(highlight, tooltip, originalElement);
89
89
  canvas.append(highlight);
90
90
  audits.push({ highlightElement: highlight, auditedElement: originalElement });
91
91
  }
92
- function buildAuditTooltip(rule) {
92
+ function buildAuditTooltip(rule, element) {
93
93
  const tooltip = document.createElement("astro-dev-overlay-tooltip");
94
94
  tooltip.sections = [
95
95
  {
@@ -99,14 +99,22 @@ var audit_default = {
99
99
  {
100
100
  content: rule.message
101
101
  }
102
- // TODO: Add a link to the file
103
- // Needs https://github.com/withastro/compiler/pull/375
104
- // {
105
- // content: '/src/somewhere/component.astro',
106
- // clickDescription: 'Click to go to file',
107
- // clickAction() {},
108
- // },
109
102
  ];
103
+ const elementFile = element.getAttribute("data-astro-source-file");
104
+ const elementPosition = element.getAttribute("data-astro-source-loc");
105
+ if (elementFile) {
106
+ const elementFileWithPosition = elementFile + (elementPosition ? ":" + elementPosition : "");
107
+ tooltip.sections.push({
108
+ content: elementFileWithPosition.slice(
109
+ window.__astro_dev_overlay__.root.length - 1
110
+ // We want to keep the final slash, so minus one.
111
+ ),
112
+ clickDescription: "Click to go to file",
113
+ async clickAction() {
114
+ await fetch("/__open-in-editor?file=" + encodeURIComponent(elementFileWithPosition));
115
+ }
116
+ });
117
+ }
110
118
  return tooltip;
111
119
  }
112
120
  function initStyle() {
@@ -7,8 +7,6 @@ export { addAttribute, createHeadAndContent, defineScriptVars, Fragment, maybeRe
7
7
  export type { AstroComponentFactory, AstroComponentInstance, ComponentSlots, RenderInstruction, } from './render/index.js';
8
8
  export { createTransitionScope, renderTransition } from './transition.js';
9
9
  export declare function mergeSlots(...slotted: unknown[]): Record<string, () => any>;
10
- /** @internal Associate JSX components with a specific renderer (see /src/vite-plugin-jsx/tag.ts) */
11
- export declare function __astro_tag_component__(Component: unknown, rendererName: string): void;
12
10
  export declare function spreadAttributes(values?: Record<any, any>, _name?: string, { class: scopedClassName }?: {
13
11
  class?: string;
14
12
  }): any;
@@ -6,11 +6,9 @@ import { extractDirectives, generateHydrateScript } from "../hydration.js";
6
6
  import { serializeProps } from "../serialize.js";
7
7
  import { shorthash } from "../shorthash.js";
8
8
  import { isPromise } from "../util.js";
9
- import {
10
- createAstroComponentInstance,
11
- isAstroComponentFactory,
12
- renderTemplate
13
- } from "./astro/index.js";
9
+ import { isAstroComponentFactory } from "./astro/factory.js";
10
+ import { renderTemplate } from "./astro/index.js";
11
+ import { createAstroComponentInstance } from "./astro/instance.js";
14
12
  import {
15
13
  Fragment,
16
14
  Renderer,
@@ -2,6 +2,7 @@ export type Fallback = 'none' | 'animate' | 'swap';
2
2
  export type Direction = 'forward' | 'back';
3
3
  export type Options = {
4
4
  history?: 'auto' | 'push' | 'replace';
5
+ formData?: FormData;
5
6
  };
6
7
  export declare const supportsViewTransitions: boolean;
7
8
  export declare const transitionEnabledOnThisPage: () => boolean;
@@ -53,9 +53,9 @@ const throttle = (cb, delay) => {
53
53
  }, delay);
54
54
  };
55
55
  };
56
- async function fetchHTML(href) {
56
+ async function fetchHTML(href, init) {
57
57
  try {
58
- const res = await fetch(href);
58
+ const res = await fetch(href, init);
59
59
  const mediaType = res.headers.get("content-type")?.replace(/;.*$/, "");
60
60
  if (mediaType !== "text/html" && mediaType !== "application/xhtml+xml") {
61
61
  return null;
@@ -253,7 +253,12 @@ async function updateDOM(newDocument, toLocation, options, popState, fallback) {
253
253
  async function transition(direction, toLocation, options, popState) {
254
254
  let finished;
255
255
  const href = toLocation.href;
256
- const response = await fetchHTML(href);
256
+ const init = {};
257
+ if (options.formData) {
258
+ init.method = "POST";
259
+ init.body = options.formData;
260
+ }
261
+ const response = await fetchHTML(href, init);
257
262
  if (response === null) {
258
263
  location.href = href;
259
264
  return;
@@ -264,7 +269,7 @@ async function transition(direction, toLocation, options, popState) {
264
269
  parser ??= new DOMParser();
265
270
  const newDocument = parser.parseFromString(response.html, response.mediaType);
266
271
  newDocument.querySelectorAll("noscript").forEach((el) => el.remove());
267
- if (!newDocument.querySelector('[name="astro-view-transitions-enabled"]')) {
272
+ if (!newDocument.querySelector('[name="astro-view-transitions-enabled"]') && !options.formData) {
268
273
  location.href = href;
269
274
  return;
270
275
  }
@@ -1,2 +1,5 @@
1
1
  import * as vite from 'vite';
2
- export default function astroTransitions(): vite.Plugin;
2
+ import type { AstroSettings } from '../@types/astro.js';
3
+ export default function astroTransitions({ settings }: {
4
+ settings: AstroSettings;
5
+ }): vite.Plugin;
@@ -3,7 +3,7 @@ const virtualModuleId = "astro:transitions";
3
3
  const resolvedVirtualModuleId = "\0" + virtualModuleId;
4
4
  const virtualClientModuleId = "astro:transitions/client";
5
5
  const resolvedVirtualClientModuleId = "\0" + virtualClientModuleId;
6
- function astroTransitions() {
6
+ function astroTransitions({ settings }) {
7
7
  return {
8
8
  name: "astro:transitions",
9
9
  async resolveId(id) {
@@ -26,6 +26,12 @@ function astroTransitions() {
26
26
  export * from "astro/transitions/router";
27
27
  `;
28
28
  }
29
+ },
30
+ transform(code, id) {
31
+ if (id.includes("ViewTransitions.astro") && id.endsWith(".ts")) {
32
+ const prefetchDisabled = settings.config.prefetch === false;
33
+ return code.replace("__PREFETCH_DISABLED__", JSON.stringify(prefetchDisabled));
34
+ }
29
35
  }
30
36
  };
31
37
  }
@@ -18,4 +18,5 @@ export default class DevPipeline extends Pipeline {
18
18
  get logger(): Readonly<Logger>;
19
19
  loadRenderers(): Promise<void>;
20
20
  static createDevelopmentEnvironment(manifest: SSRManifest, settings: AstroSettings, logger: Logger, loader: ModuleLoader): Environment;
21
+ handleFallback(): Promise<void>;
21
22
  }
@@ -61,6 +61,8 @@ class DevPipeline extends Pipeline {
61
61
  async #handleEndpointResult(_, response) {
62
62
  return response;
63
63
  }
64
+ async handleFallback() {
65
+ }
64
66
  }
65
67
  export {
66
68
  DevPipeline as default
@@ -59,6 +59,15 @@ function createVitePluginAstroServer({
59
59
  };
60
60
  }
61
61
  function createDevelopmentManifest(settings) {
62
+ let i18nManifest = void 0;
63
+ if (settings.config.experimental.i18n) {
64
+ i18nManifest = {
65
+ fallback: settings.config.experimental.i18n.fallback,
66
+ routingStrategy: settings.config.experimental.i18n.routingStrategy,
67
+ defaultLocale: settings.config.experimental.i18n.defaultLocale,
68
+ locales: settings.config.experimental.i18n.locales
69
+ };
70
+ }
62
71
  return {
63
72
  compressHTML: settings.config.compressHTML,
64
73
  assets: /* @__PURE__ */ new Set(),
@@ -70,7 +79,8 @@ function createDevelopmentManifest(settings) {
70
79
  base: settings.config.base,
71
80
  assetsPrefix: settings.config.build.assetsPrefix,
72
81
  site: settings.config.site ? new URL(settings.config.base, settings.config.site).toString() : settings.config.site,
73
- componentMetadata: /* @__PURE__ */ new Map()
82
+ componentMetadata: /* @__PURE__ */ new Map(),
83
+ i18n: i18nManifest
74
84
  };
75
85
  }
76
86
  export {