astro 3.4.3 → 3.5.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 (158) hide show
  1. package/client.d.ts +86 -0
  2. package/components/Code.astro +37 -4
  3. package/components/Image.astro +2 -2
  4. package/components/Picture.astro +19 -5
  5. package/components/ViewTransitions.astro +39 -38
  6. package/content-module.template.mjs +4 -14
  7. package/dist/@types/astro.d.ts +223 -5
  8. package/dist/assets/build/generate.d.ts +2 -1
  9. package/dist/assets/build/generate.js +16 -5
  10. package/dist/assets/consts.d.ts +1 -0
  11. package/dist/assets/consts.js +2 -0
  12. package/dist/assets/endpoint/generic.js +6 -2
  13. package/dist/assets/internal.js +11 -2
  14. package/dist/assets/services/service.d.ts +10 -10
  15. package/dist/assets/services/service.js +2 -1
  16. package/dist/assets/services/vendor/squoosh/image-pool.d.ts +1 -2
  17. package/dist/assets/types.d.ts +19 -9
  18. package/dist/assets/utils/emitAsset.js +5 -0
  19. package/dist/assets/utils/metadata.d.ts +1 -2
  20. package/dist/assets/utils/proxy.d.ts +1 -0
  21. package/dist/assets/utils/proxy.js +16 -0
  22. package/dist/assets/utils/queryParams.d.ts +1 -1
  23. package/dist/assets/utils/transformToPath.d.ts +1 -1
  24. package/dist/assets/utils/transformToPath.js +8 -3
  25. package/dist/assets/vite-plugin-assets.js +26 -11
  26. package/dist/cli/build/index.js +1 -1
  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 +72 -4
  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/messages.js +2 -2
  88. package/dist/core/middleware/index.d.ts +7 -3
  89. package/dist/core/middleware/index.js +3 -2
  90. package/dist/core/middleware/loadMiddleware.d.ts +1 -2
  91. package/dist/core/middleware/loadMiddleware.js +3 -4
  92. package/dist/core/middleware/sequence.d.ts +2 -2
  93. package/dist/core/middleware/sequence.js +3 -2
  94. package/dist/core/middleware/vite-plugin.d.ts +9 -0
  95. package/dist/core/middleware/vite-plugin.js +101 -0
  96. package/dist/core/pipeline.d.ts +1 -1
  97. package/dist/core/pipeline.js +6 -4
  98. package/dist/core/preview/static-preview-server.js +3 -1
  99. package/dist/core/preview/vite-plugin-astro-preview.js +13 -2
  100. package/dist/core/redirects/helpers.d.ts +1 -0
  101. package/dist/core/redirects/helpers.js +4 -0
  102. package/dist/core/render/context.d.ts +24 -1
  103. package/dist/core/render/context.js +96 -2
  104. package/dist/core/render/core.d.ts +2 -14
  105. package/dist/core/render/core.js +12 -52
  106. package/dist/core/render/index.d.ts +2 -3
  107. package/dist/core/render/index.js +3 -4
  108. package/dist/core/render/params-and-props.d.ts +1 -1
  109. package/dist/core/render/params-and-props.js +5 -2
  110. package/dist/core/render/result.d.ts +1 -0
  111. package/dist/core/render/result.js +23 -0
  112. package/dist/core/render/route-cache.d.ts +1 -1
  113. package/dist/core/render/route-cache.js +17 -11
  114. package/dist/core/routing/manifest/create.js +118 -4
  115. package/dist/core/sync/index.d.ts +2 -24
  116. package/dist/i18n/index.d.ts +54 -0
  117. package/dist/i18n/index.js +91 -0
  118. package/dist/i18n/middleware.d.ts +2 -0
  119. package/dist/i18n/middleware.js +62 -0
  120. package/dist/i18n/vite-plugin-i18n.d.ts +7 -0
  121. package/dist/i18n/vite-plugin-i18n.js +62 -0
  122. package/dist/integrations/astroFeaturesValidation.js +4 -1
  123. package/dist/integrations/index.js +12 -0
  124. package/dist/prefetch/index.d.ts +31 -0
  125. package/dist/prefetch/index.js +176 -0
  126. package/dist/prefetch/vite-plugin-prefetch.d.ts +5 -0
  127. package/dist/prefetch/vite-plugin-prefetch.js +43 -0
  128. package/dist/runtime/client/dev-overlay/entrypoint.js +2 -2
  129. package/dist/runtime/client/dev-overlay/overlay.d.ts +10 -2
  130. package/dist/runtime/client/dev-overlay/overlay.js +47 -28
  131. package/dist/runtime/client/dev-overlay/plugins/astro.d.ts +1 -0
  132. package/dist/runtime/client/dev-overlay/plugins/astro.js +44 -9
  133. package/dist/runtime/client/dev-overlay/plugins/audit.d.ts +2 -1
  134. package/dist/runtime/client/dev-overlay/plugins/audit.js +101 -24
  135. package/dist/runtime/client/dev-overlay/plugins/xray.d.ts +1 -0
  136. package/dist/runtime/client/dev-overlay/plugins/xray.js +22 -0
  137. package/dist/runtime/client/dev-overlay/ui-library/card.js +2 -0
  138. package/dist/runtime/client/dev-overlay/ui-library/icons.d.ts +3 -0
  139. package/dist/runtime/client/dev-overlay/ui-library/icons.js +4 -1
  140. package/dist/runtime/client/dev-overlay/ui-library/tooltip.js +1 -0
  141. package/dist/runtime/client/dev-overlay/ui-library/window.js +1 -0
  142. package/dist/runtime/server/index.d.ts +0 -2
  143. package/dist/runtime/server/render/component.js +3 -5
  144. package/dist/transitions/router.d.ts +1 -0
  145. package/dist/transitions/router.js +10 -5
  146. package/dist/transitions/vite-plugin-transitions.d.ts +4 -1
  147. package/dist/transitions/vite-plugin-transitions.js +7 -1
  148. package/dist/vite-plugin-astro-server/devPipeline.d.ts +1 -0
  149. package/dist/vite-plugin-astro-server/devPipeline.js +2 -0
  150. package/dist/vite-plugin-astro-server/plugin.js +11 -1
  151. package/dist/vite-plugin-astro-server/route.js +113 -51
  152. package/dist/vite-plugin-head/index.js +1 -1
  153. package/dist/vite-plugin-markdown/index.js +1 -0
  154. package/dist/vite-plugin-scripts/index.js +2 -1
  155. package/package.json +7 -5
  156. package/tsconfigs/base.json +1 -1
  157. package/dist/core/endpoint/dev/index.d.ts +0 -2
  158. package/dist/core/endpoint/dev/index.js +0 -17
package/client.d.ts CHANGED
@@ -119,6 +119,92 @@ declare module 'astro:transitions/client' {
119
119
  export const supportsViewTransitions: TransitionRouterModule['supportsViewTransitions'];
120
120
  export const transitionEnabledOnThisPage: TransitionRouterModule['transitionEnabledOnThisPage'];
121
121
  export const navigate: TransitionRouterModule['navigate'];
122
+ export type Options = import('./dist/transitions/router.js').Options;
123
+ }
124
+
125
+ declare module 'astro:prefetch' {
126
+ export { prefetch, PrefetchOptions } from 'astro/prefetch';
127
+ }
128
+
129
+ declare module 'astro:i18n' {
130
+ export type GetLocaleOptions = import('./dist/i18n/index.js').GetLocaleOptions;
131
+
132
+ /**
133
+ * @param {string} locale A locale
134
+ * @param {string} [path=""] An optional path to add after the `locale`.
135
+ * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path
136
+ * @return {string}
137
+ *
138
+ * Returns a _relative_ path with passed locale.
139
+ *
140
+ * ## Errors
141
+ *
142
+ * Throws an error if the locale doesn't exist in the list of locales defined in the configuration.
143
+ *
144
+ * ## Examples
145
+ *
146
+ * ```js
147
+ * import { getRelativeLocaleUrl } from "astro:i18n";
148
+ * getRelativeLocaleUrl("es"); // /es
149
+ * getRelativeLocaleUrl("es", "getting-started"); // /es/getting-started
150
+ * getRelativeLocaleUrl("es_US", "getting-started", { prependWith: "blog" }); // /blog/es-us/getting-started
151
+ * getRelativeLocaleUrl("es_US", "getting-started", { prependWith: "blog", normalizeLocale: false }); // /blog/es_US/getting-started
152
+ * ```
153
+ */
154
+ export const getRelativeLocaleUrl: (
155
+ locale: string,
156
+ path?: string,
157
+ options?: GetLocaleOptions
158
+ ) => string;
159
+
160
+ /**
161
+ *
162
+ * @param {string} locale A locale
163
+ * @param {string} [path=""] An optional path to add after the `locale`.
164
+ * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path
165
+ * @return {string}
166
+ *
167
+ * Returns an absolute path with the passed locale. The behaviour is subject to change based on `site` configuration.
168
+ * If _not_ provided, the function will return a _relative_ URL.
169
+ *
170
+ * ## Errors
171
+ *
172
+ * Throws an error if the locale doesn't exist in the list of locales defined in the configuration.
173
+ *
174
+ * ## Examples
175
+ *
176
+ * If `site` is `https://example.com`:
177
+ *
178
+ * ```js
179
+ * import { getAbsoluteLocaleUrl } from "astro:i18n";
180
+ * getAbsoluteLocaleUrl("es"); // https://example.com/es
181
+ * getAbsoluteLocaleUrl("es", "getting-started"); // https://example.com/es/getting-started
182
+ * getAbsoluteLocaleUrl("es_US", "getting-started", { prependWith: "blog" }); // https://example.com/blog/es-us/getting-started
183
+ * getAbsoluteLocaleUrl("es_US", "getting-started", { prependWith: "blog", normalizeLocale: false }); // https://example.com/blog/es_US/getting-started
184
+ * ```
185
+ */
186
+ export const getAbsoluteLocaleUrl: (
187
+ locale: string,
188
+ path?: string,
189
+ options?: GetLocaleOptions
190
+ ) => string;
191
+
192
+ /**
193
+ * @param {string} [path=""] An optional path to add after the `locale`.
194
+ * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path
195
+ * @return {string[]}
196
+ *
197
+ * Works like `getRelativeLocaleUrl` but it emits the relative URLs for ALL locales:
198
+ */
199
+ export const getRelativeLocaleUrlList: (path?: string, options?: GetLocaleOptions) => string[];
200
+ /**
201
+ * @param {string} [path=""] An optional path to add after the `locale`.
202
+ * @param {import('./dist/i18n/index.js').GetLocaleOptions} options Customise the generated path
203
+ * @return {string[]}
204
+ *
205
+ * Works like `getAbsoluteLocaleUrl` but it emits the absolute URLs for ALL locales:
206
+ */
207
+ export const getAbsoluteLocaleUrlList: (path?: string, options?: GetLocaleOptions) => string[];
122
208
  }
123
209
 
124
210
  declare module 'astro:middleware' {
@@ -1,4 +1,7 @@
1
1
  ---
2
+ import path from 'node:path';
3
+ import fs from 'node:fs';
4
+ import { fileURLToPath } from 'node:url';
2
5
  import type {
3
6
  BuiltinLanguage,
4
7
  BuiltinTheme,
@@ -29,6 +32,11 @@ interface Props {
29
32
  * @default "github-dark"
30
33
  */
31
34
  theme?: BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw;
35
+ /**
36
+ * Multiple themes to style with -- alternative to "theme" option.
37
+ * Supports all themes found above; see https://github.com/antfu/shikiji#lightdark-dual-themes for more information.
38
+ */
39
+ experimentalThemes?: Record<string, BuiltinTheme | ThemeRegistration | ThemeRegistrationRaw>;
32
40
  /**
33
41
  * Enable word wrapping.
34
42
  * - true: enabled.
@@ -50,14 +58,32 @@ const {
50
58
  code,
51
59
  lang = 'plaintext',
52
60
  theme = 'github-dark',
61
+ experimentalThemes = {},
53
62
  wrap = false,
54
63
  inline = false,
55
64
  } = Astro.props;
56
65
 
57
66
  // shiki -> shikiji compat
58
67
  if (typeof lang === 'object') {
59
- // `id` renamed to `name
60
- if ((lang as any).id && !lang.name) {
68
+ // shikiji does not support `path`
69
+ // https://github.com/shikijs/shiki/blob/facb6ff37996129626f8066a5dccb4608e45f649/packages/shiki/src/loader.ts#L98
70
+ const langPath = (lang as any).path;
71
+ if (langPath) {
72
+ // shiki resolves path from within its package directory :shrug:
73
+ const astroRoot = fileURLToPath(new URL('../', import.meta.url));
74
+ const normalizedPath = path.isAbsolute(langPath) ? langPath : path.resolve(astroRoot, langPath);
75
+ try {
76
+ const content = fs.readFileSync(normalizedPath, 'utf-8');
77
+ const parsed = JSON.parse(content);
78
+ Object.assign(lang, parsed);
79
+ } catch (e) {
80
+ throw new Error(`Unable to find language file at ${normalizedPath}`, {
81
+ cause: e,
82
+ });
83
+ }
84
+ }
85
+ // `id` renamed to `name` (always override)
86
+ if ((lang as any).id) {
61
87
  lang.name = (lang as any).id;
62
88
  }
63
89
  // `grammar` flattened to lang itself
@@ -68,12 +94,15 @@ if (typeof lang === 'object') {
68
94
 
69
95
  const highlighter = await getCachedHighlighter({
70
96
  langs: [lang],
71
- themes: [theme],
97
+ themes: Object.values(experimentalThemes).length ? Object.values(experimentalThemes) : [theme],
72
98
  });
73
99
 
100
+ const themeOptions = Object.values(experimentalThemes).length
101
+ ? { themes: experimentalThemes }
102
+ : { theme };
74
103
  const html = highlighter.codeToHtml(code, {
75
104
  lang: typeof lang === 'string' ? lang : lang.name,
76
- theme,
105
+ ...themeOptions,
77
106
  transforms: {
78
107
  pre(node) {
79
108
  // Swap to `code` tag if inline
@@ -103,6 +132,10 @@ const html = highlighter.codeToHtml(code, {
103
132
  }
104
133
  },
105
134
  root(node) {
135
+ if (Object.values(experimentalThemes).length) {
136
+ return;
137
+ }
138
+
106
139
  // theme.id for shiki -> shikiji compat
107
140
  const themeName = typeof theme === 'string' ? theme : theme.name;
108
141
  if (themeName === 'css-variables') {
@@ -1,6 +1,7 @@
1
1
  ---
2
2
  import { getImage, type LocalImageProps, type RemoteImageProps } from 'astro:assets';
3
3
  import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
4
+ import type { HTMLAttributes } from '../types';
4
5
 
5
6
  // The TypeScript diagnostic for JSX props uses the last member of the union to suggest props, so it would be better for
6
7
  // LocalImageProps to be last. Unfortunately, when we do this the error messages that remote images get are complete nonsense
@@ -24,8 +25,7 @@ if (typeof props.height === 'string') {
24
25
 
25
26
  const image = await getImage(props);
26
27
 
27
- const additionalAttributes: Record<string, any> = {};
28
-
28
+ const additionalAttributes: HTMLAttributes<'img'> = {};
29
29
  if (image.srcSet.values.length > 0) {
30
30
  additionalAttributes.srcset = image.srcSet.attribute;
31
31
  }
@@ -17,8 +17,9 @@ const defaultFallbackFormat = 'png' as const;
17
17
  // Certain formats don't want PNG fallbacks:
18
18
  // - GIF will typically want to stay as a gif, either for animation or for the lower amount of colors
19
19
  // - SVGs can't be converted to raster formats in most cases
20
+ // - JPEGs compress photographs and high-noise images better than PNG in most cases
20
21
  // For those, we'll use the original format as the fallback instead.
21
- const specialFormatsFallback = ['gif', 'svg'] as const;
22
+ const specialFormatsFallback = ['gif', 'svg', 'jpg', 'jpeg'] as const;
22
23
 
23
24
  const { formats = defaultFormats, pictureAttributes = {}, fallbackFormat, ...props } = Astro.props;
24
25
 
@@ -49,9 +50,16 @@ const fallbackImage = await getImage({
49
50
  densities: props.densities,
50
51
  });
51
52
 
52
- const additionalAttributes: Record<string, any> = {};
53
+ const imgAdditionalAttributes: HTMLAttributes<'img'> = {};
54
+ const sourceAdditionaAttributes: HTMLAttributes<'source'> = {};
55
+
56
+ // Propagate the `sizes` attribute to the `source` elements
57
+ if (props.sizes) {
58
+ sourceAdditionaAttributes.sizes = props.sizes;
59
+ }
60
+
53
61
  if (fallbackImage.srcSet.values.length > 0) {
54
- additionalAttributes.srcset = fallbackImage.srcSet.attribute;
62
+ imgAdditionalAttributes.srcset = fallbackImage.srcSet.attribute;
55
63
  }
56
64
  ---
57
65
 
@@ -62,8 +70,14 @@ if (fallbackImage.srcSet.values.length > 0) {
62
70
  props.densities || (!props.densities && !props.widths)
63
71
  ? `${image.src}${image.srcSet.values.length > 0 ? ', ' + image.srcSet.attribute : ''}`
64
72
  : image.srcSet.attribute;
65
- return <source srcset={srcsetAttribute} type={'image/' + image.options.format} />;
73
+ return (
74
+ <source
75
+ srcset={srcsetAttribute}
76
+ type={'image/' + image.options.format}
77
+ {...sourceAdditionaAttributes}
78
+ />
79
+ );
66
80
  })
67
81
  }
68
- <img src={fallbackImage.src} {...additionalAttributes} {...fallbackImage.attributes} />
82
+ <img src={fallbackImage.src} {...imgAdditionalAttributes} {...fallbackImage.attributes} />
69
83
  </picture>
@@ -3,9 +3,10 @@ type Fallback = 'none' | 'animate' | 'swap';
3
3
 
4
4
  export interface Props {
5
5
  fallback?: Fallback;
6
+ handleForms?: boolean;
6
7
  }
7
8
 
8
- const { fallback = 'animate' } = Astro.props;
9
+ const { fallback = 'animate', handleForms } = Astro.props;
9
10
  ---
10
11
 
11
12
  <style is:global>
@@ -24,12 +25,13 @@ const { fallback = 'animate' } = Astro.props;
24
25
  </style>
25
26
  <meta name="astro-view-transitions-enabled" content="true" />
26
27
  <meta name="astro-view-transitions-fallback" content={fallback} />
28
+ {handleForms ? <meta name="astro-view-transitions-forms" content="true" /> : ''}
27
29
  <script>
28
- import {
29
- supportsViewTransitions,
30
- transitionEnabledOnThisPage,
31
- navigate,
32
- } from 'astro:transitions/client';
30
+ import type { Options } from 'astro:transitions/client';
31
+ import { supportsViewTransitions, navigate } from 'astro:transitions/client';
32
+ // NOTE: import from `astro/prefetch` as `astro:prefetch` requires the `prefetch` config to be enabled
33
+ import { init } from 'astro/prefetch';
34
+
33
35
  export type Fallback = 'none' | 'animate' | 'swap';
34
36
 
35
37
  function getFallback(): Fallback {
@@ -40,19 +42,8 @@ const { fallback = 'animate' } = Astro.props;
40
42
  return 'animate';
41
43
  }
42
44
 
43
- // Prefetching
44
- function maybePrefetch(pathname: string) {
45
- if (document.querySelector(`link[rel=prefetch][href="${pathname}"]`)) return;
46
- // @ts-expect-error: connection might exist
47
- if (navigator.connection) {
48
- // @ts-expect-error: connection does exist
49
- let conn = navigator.connection;
50
- if (conn.saveData || /(2|3)g/.test(conn.effectiveType || '')) return;
51
- }
52
- let link = document.createElement('link');
53
- link.setAttribute('rel', 'prefetch');
54
- link.setAttribute('href', pathname);
55
- document.head.append(link);
45
+ function isReloadEl(el: HTMLElement): boolean {
46
+ return el.dataset.astroReload !== undefined;
56
47
  }
57
48
 
58
49
  if (supportsViewTransitions || getFallback() !== 'none') {
@@ -67,7 +58,7 @@ const { fallback = 'animate' } = Astro.props;
67
58
  if (
68
59
  !link ||
69
60
  !(link instanceof HTMLAnchorElement) ||
70
- link.dataset.astroReload !== undefined ||
61
+ isReloadEl(link) ||
71
62
  link.hasAttribute('download') ||
72
63
  !link.href ||
73
64
  (link.target && link.target !== '_self') ||
@@ -89,23 +80,33 @@ const { fallback = 'animate' } = Astro.props;
89
80
  });
90
81
  });
91
82
 
92
- ['mouseenter', 'touchstart', 'focus'].forEach((evName) => {
93
- document.addEventListener(
94
- evName,
95
- (ev) => {
96
- if (ev.target instanceof HTMLAnchorElement) {
97
- let el = ev.target;
98
- if (
99
- el.origin === location.origin &&
100
- el.pathname !== location.pathname &&
101
- transitionEnabledOnThisPage()
102
- ) {
103
- maybePrefetch(el.pathname);
104
- }
105
- }
106
- },
107
- { passive: true, capture: true }
108
- );
109
- });
83
+ if (document.querySelector('[name="astro-view-transitions-forms"]')) {
84
+ document.addEventListener('submit', (ev) => {
85
+ let el = ev.target as HTMLElement;
86
+ if (el.tagName !== 'FORM' || isReloadEl(el)) {
87
+ return;
88
+ }
89
+
90
+ const form = el as HTMLFormElement;
91
+ const formData = new FormData(form);
92
+ let action = form.action;
93
+ const options: Options = {};
94
+ if (form.method === 'get') {
95
+ const params = new URLSearchParams(formData as any);
96
+ const url = new URL(action);
97
+ url.search = params.toString();
98
+ action = url.toString();
99
+ } else {
100
+ options.formData = formData;
101
+ }
102
+ ev.preventDefault();
103
+ navigate(action, options);
104
+ });
105
+ }
106
+
107
+ // @ts-expect-error injected by vite-plugin-transitions for treeshaking
108
+ if (!__PREFETCH_DISABLED__) {
109
+ init({ prefetchAll: true });
110
+ }
110
111
  }
111
112
  </script>
@@ -9,21 +9,18 @@ import {
9
9
  createReference,
10
10
  } from 'astro/content/runtime';
11
11
 
12
+ export { defineCollection } from 'astro/content/runtime';
12
13
  export { z } from 'astro/zod';
13
14
 
14
15
  const contentDir = '@@CONTENT_DIR@@';
15
16
 
16
- const contentEntryGlob = import.meta.glob('@@CONTENT_ENTRY_GLOB_PATH@@', {
17
- query: { astroContentCollectionEntry: true },
18
- });
17
+ const contentEntryGlob = '@@CONTENT_ENTRY_GLOB_PATH@@';
19
18
  const contentCollectionToEntryMap = createCollectionToGlobResultMap({
20
19
  globResult: contentEntryGlob,
21
20
  contentDir,
22
21
  });
23
22
 
24
- const dataEntryGlob = import.meta.glob('@@DATA_ENTRY_GLOB_PATH@@', {
25
- query: { astroDataCollectionEntry: true },
26
- });
23
+ const dataEntryGlob = '@@DATA_ENTRY_GLOB_PATH@@';
27
24
  const dataCollectionToEntryMap = createCollectionToGlobResultMap({
28
25
  globResult: dataEntryGlob,
29
26
  contentDir,
@@ -45,19 +42,12 @@ function createGlobLookup(glob) {
45
42
  };
46
43
  }
47
44
 
48
- const renderEntryGlob = import.meta.glob('@@RENDER_ENTRY_GLOB_PATH@@', {
49
- query: { astroRenderContent: true },
50
- });
45
+ const renderEntryGlob = '@@RENDER_ENTRY_GLOB_PATH@@';
51
46
  const collectionToRenderEntryMap = createCollectionToGlobResultMap({
52
47
  globResult: renderEntryGlob,
53
48
  contentDir,
54
49
  });
55
50
 
56
- export function defineCollection(config) {
57
- if (!config.type) config.type = 'content';
58
- return config;
59
- }
60
-
61
51
  export const getCollection = createGetCollection({
62
52
  contentCollectionToEntryMap,
63
53
  dataCollectionToEntryMap,