astro 3.0.0-beta.4 → 3.0.0-rc.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.
Files changed (151) hide show
  1. package/components/ViewTransitions.astro +105 -60
  2. package/components/shiki-themes.js +0 -6
  3. package/content-types.template.d.ts +2 -24
  4. package/dist/@types/astro.d.ts +22 -78
  5. package/dist/assets/build/generate.d.ts +2 -2
  6. package/dist/assets/build/generate.js +13 -20
  7. package/dist/assets/image-endpoint.js +2 -2
  8. package/dist/cli/add/index.js +42 -51
  9. package/dist/cli/check/index.js +6 -8
  10. package/dist/cli/flags.d.ts +2 -2
  11. package/dist/cli/flags.js +4 -3
  12. package/dist/cli/install-package.d.ts +2 -2
  13. package/dist/cli/install-package.js +7 -9
  14. package/dist/config/index.js +7 -6
  15. package/dist/config/vite-plugin-content-listen.d.ts +3 -3
  16. package/dist/config/vite-plugin-content-listen.js +2 -2
  17. package/dist/content/server-listeners.d.ts +3 -3
  18. package/dist/content/server-listeners.js +15 -19
  19. package/dist/content/types-generator.d.ts +3 -3
  20. package/dist/content/types-generator.js +7 -11
  21. package/dist/content/utils.js +4 -1
  22. package/dist/core/app/index.js +22 -10
  23. package/dist/core/app/ssrPipeline.d.ts +1 -1
  24. package/dist/core/app/ssrPipeline.js +3 -25
  25. package/dist/core/app/types.d.ts +1 -0
  26. package/dist/core/build/buildPipeline.d.ts +5 -7
  27. package/dist/core/build/buildPipeline.js +17 -43
  28. package/dist/core/build/generate.js +42 -45
  29. package/dist/core/build/index.js +31 -34
  30. package/dist/core/build/page-data.d.ts +2 -2
  31. package/dist/core/build/page-data.js +2 -4
  32. package/dist/core/build/plugins/index.js +1 -1
  33. package/dist/core/build/plugins/plugin-internals.js +14 -9
  34. package/dist/core/build/plugins/plugin-manifest.d.ts +2 -2
  35. package/dist/core/build/plugins/plugin-manifest.js +17 -8
  36. package/dist/core/build/plugins/plugin-middleware.js +4 -2
  37. package/dist/core/build/plugins/plugin-pages.d.ts +1 -1
  38. package/dist/core/build/plugins/plugin-ssr.js +1 -1
  39. package/dist/core/build/static-build.js +9 -10
  40. package/dist/core/build/types.d.ts +3 -4
  41. package/dist/core/compile/compile.js +0 -2
  42. package/dist/core/config/config.js +0 -52
  43. package/dist/core/config/index.d.ts +1 -1
  44. package/dist/core/config/index.js +2 -2
  45. package/dist/core/config/logging.d.ts +2 -2
  46. package/dist/core/config/logging.js +7 -6
  47. package/dist/core/config/schema.d.ts +248 -83
  48. package/dist/core/config/schema.js +2 -2
  49. package/dist/core/constants.js +1 -1
  50. package/dist/core/create-vite.d.ts +3 -3
  51. package/dist/core/create-vite.js +11 -11
  52. package/dist/core/dev/container.d.ts +5 -5
  53. package/dist/core/dev/container.js +14 -10
  54. package/dist/core/dev/dev.js +5 -7
  55. package/dist/core/dev/restart.js +9 -10
  56. package/dist/core/endpoint/dev/index.d.ts +1 -1
  57. package/dist/core/endpoint/index.d.ts +6 -9
  58. package/dist/core/endpoint/index.js +70 -18
  59. package/dist/core/errors/errors-data.d.ts +1 -1
  60. package/dist/core/errors/index.d.ts +1 -1
  61. package/dist/core/errors/index.js +2 -2
  62. package/dist/core/logger/core.d.ts +3 -1
  63. package/dist/core/logger/core.js +8 -2
  64. package/dist/core/messages.js +4 -4
  65. package/dist/core/middleware/callMiddleware.d.ts +1 -1
  66. package/dist/core/middleware/callMiddleware.js +2 -4
  67. package/dist/core/pipeline.d.ts +3 -9
  68. package/dist/core/pipeline.js +3 -12
  69. package/dist/core/preview/index.js +5 -5
  70. package/dist/core/preview/static-preview-server.d.ts +2 -2
  71. package/dist/core/preview/static-preview-server.js +3 -5
  72. package/dist/core/redirects/component.js +0 -1
  73. package/dist/core/render/context.js +1 -1
  74. package/dist/core/render/core.d.ts +2 -5
  75. package/dist/core/render/core.js +8 -10
  76. package/dist/core/render/environment.d.ts +2 -2
  77. package/dist/core/render/index.d.ts +1 -1
  78. package/dist/core/render/params-and-props.d.ts +2 -2
  79. package/dist/core/render/params-and-props.js +3 -3
  80. package/dist/core/render/result.d.ts +2 -2
  81. package/dist/core/render/result.js +5 -7
  82. package/dist/core/render/route-cache.d.ts +6 -6
  83. package/dist/core/render/route-cache.js +8 -10
  84. package/dist/core/request.d.ts +3 -3
  85. package/dist/core/request.js +3 -5
  86. package/dist/core/routing/manifest/create.d.ts +2 -2
  87. package/dist/core/routing/manifest/create.js +3 -4
  88. package/dist/core/routing/validation.d.ts +2 -2
  89. package/dist/core/routing/validation.js +3 -6
  90. package/dist/core/sync/index.d.ts +3 -3
  91. package/dist/core/sync/index.js +10 -11
  92. package/dist/integrations/astroFeaturesValidation.d.ts +2 -2
  93. package/dist/integrations/astroFeaturesValidation.js +19 -27
  94. package/dist/integrations/index.d.ts +19 -19
  95. package/dist/integrations/index.js +49 -48
  96. package/dist/runtime/compiler/index.d.ts +1 -1
  97. package/dist/runtime/compiler/index.js +8 -8
  98. package/dist/runtime/server/endpoint.d.ts +2 -2
  99. package/dist/runtime/server/endpoint.js +4 -6
  100. package/dist/runtime/server/hydration.js +0 -5
  101. package/dist/runtime/server/render/any.js +8 -2
  102. package/dist/runtime/server/render/astro/render-template.js +11 -3
  103. package/dist/runtime/server/render/common.d.ts +3 -2
  104. package/dist/runtime/server/render/common.js +13 -15
  105. package/dist/runtime/server/render/component.d.ts +1 -1
  106. package/dist/runtime/server/render/component.js +16 -12
  107. package/dist/runtime/server/render/head.d.ts +1 -1
  108. package/dist/runtime/server/render/head.js +3 -2
  109. package/dist/runtime/server/render/index.d.ts +1 -1
  110. package/dist/runtime/server/render/instruction.d.ts +16 -0
  111. package/dist/runtime/server/render/instruction.js +13 -0
  112. package/dist/runtime/server/render/slot.d.ts +1 -1
  113. package/dist/runtime/server/render/util.d.ts +23 -0
  114. package/dist/runtime/server/render/util.js +19 -2
  115. package/dist/runtime/server/transition.js +66 -54
  116. package/dist/runtime/server/util.d.ts +0 -1
  117. package/dist/runtime/server/util.js +0 -23
  118. package/dist/transitions/index.js +16 -15
  119. package/dist/transitions/vite-plugin-transitions.d.ts +1 -4
  120. package/dist/transitions/vite-plugin-transitions.js +1 -15
  121. package/dist/vite-plugin-astro/compile.d.ts +3 -3
  122. package/dist/vite-plugin-astro/compile.js +2 -2
  123. package/dist/vite-plugin-astro/hmr.d.ts +3 -3
  124. package/dist/vite-plugin-astro/hmr.js +4 -5
  125. package/dist/vite-plugin-astro/index.d.ts +3 -3
  126. package/dist/vite-plugin-astro/index.js +3 -3
  127. package/dist/vite-plugin-astro-server/base.d.ts +2 -2
  128. package/dist/vite-plugin-astro-server/base.js +4 -6
  129. package/dist/vite-plugin-astro-server/common.d.ts +2 -2
  130. package/dist/vite-plugin-astro-server/common.js +2 -3
  131. package/dist/vite-plugin-astro-server/devPipeline.d.ts +6 -9
  132. package/dist/vite-plugin-astro-server/devPipeline.js +9 -40
  133. package/dist/vite-plugin-astro-server/plugin.d.ts +3 -3
  134. package/dist/vite-plugin-astro-server/plugin.js +8 -7
  135. package/dist/vite-plugin-astro-server/route.js +9 -7
  136. package/dist/vite-plugin-inject-env-ts/index.d.ts +5 -5
  137. package/dist/vite-plugin-inject-env-ts/index.js +14 -6
  138. package/dist/vite-plugin-integrations-container/index.d.ts +3 -3
  139. package/dist/vite-plugin-integrations-container/index.js +2 -2
  140. package/dist/vite-plugin-markdown/index.d.ts +3 -3
  141. package/dist/vite-plugin-markdown/index.js +2 -4
  142. package/dist/vite-plugin-mdx/index.d.ts +2 -2
  143. package/dist/vite-plugin-scanner/index.d.ts +3 -3
  144. package/dist/vite-plugin-scanner/index.js +3 -5
  145. package/package.json +35 -36
  146. package/dist/runtime/server/render/types.d.ts +0 -12
  147. package/dist/runtime/server/render/types.js +0 -0
  148. package/dist/vite-plugin-astro-server/environment.d.ts +0 -5
  149. package/dist/vite-plugin-astro-server/environment.js +0 -24
  150. package/dist/vite-plugin-mdx/import-source.d.ts +0 -3
  151. package/dist/vite-plugin-mdx/import-source.js +0 -35
@@ -17,25 +17,24 @@ const { fallback = 'animate' } = Astro.props as Props;
17
17
  index: number;
18
18
  scrollY: number;
19
19
  };
20
- type Events = 'astro:load' | 'astro:beforeload';
20
+ type Events = 'astro:page-load' | 'astro:after-swap';
21
21
 
22
22
  const persistState = (state: State) => history.replaceState(state, '');
23
+ const supportsViewTransitions = !!document.startViewTransition;
24
+ const transitionEnabledOnThisPage = () =>
25
+ !!document.querySelector('[name="astro-view-transitions-enabled"]');
26
+ const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
27
+ const onPageLoad = () => triggerEvent('astro:page-load');
28
+ const PERSIST_ATTR = 'data-astro-transition-persist';
23
29
 
24
30
  // The History API does not tell you if navigation is forward or back, so
25
31
  // you can figure it using an index. On pushState the index is incremented so you
26
32
  // can use that to determine popstate if going forward or back.
27
33
  let currentHistoryIndex = history.state?.index || 0;
28
- if (!history.state) {
34
+ if (!history.state && transitionEnabledOnThisPage()) {
29
35
  persistState({ index: currentHistoryIndex, scrollY: 0 });
30
36
  }
31
37
 
32
- const supportsViewTransitions = !!document.startViewTransition;
33
- const transitionEnabledOnThisPage = () =>
34
- !!document.querySelector('[name="astro-view-transitions-enabled"]');
35
- const triggerEvent = (name: Events) => document.dispatchEvent(new Event(name));
36
- const onload = () => triggerEvent('astro:load');
37
- const PERSIST_ATTR = 'data-astro-transition-persist';
38
-
39
38
  const throttle = (cb: (...args: any[]) => any, delay: number) => {
40
39
  let wait = false;
41
40
  // During the waiting time additional events are lost.
@@ -101,9 +100,8 @@ const { fallback = 'animate' } = Astro.props as Props;
101
100
 
102
101
  const parser = new DOMParser();
103
102
 
104
- async function updateDOM(dir: Direction, html: string, state?: State, fallback?: Fallback) {
103
+ async function updateDOM(html: string, state?: State, fallback?: Fallback) {
105
104
  const doc = parser.parseFromString(html, 'text/html');
106
- doc.documentElement.dataset.astroTransition = dir;
107
105
 
108
106
  // Check for a head element that should persist, either because it has the data
109
107
  // attribute or is a link el.
@@ -138,6 +136,18 @@ const { fallback = 'animate' } = Astro.props as Props;
138
136
  // Remove them before swapping.
139
137
  doc.querySelectorAll('head noscript').forEach((el) => el.remove());
140
138
 
139
+ // swap attributes of the html element
140
+ // - delete all attributes from the current document
141
+ // - insert all attributes from doc
142
+ // - reinsert all original attributes that are named 'data-astro-*'
143
+ const html = document.documentElement;
144
+ const astro = [...html.attributes].filter(
145
+ ({ name }) => (html.removeAttribute(name), name.startsWith('data-astro-'))
146
+ );
147
+ [...doc.documentElement.attributes, ...astro].forEach(({ name, value }) =>
148
+ html.setAttribute(name, value)
149
+ );
150
+
141
151
  // Swap head
142
152
  for (const el of Array.from(document.head.children)) {
143
153
  const newEl = persistedHeadElement(el);
@@ -166,17 +176,24 @@ const { fallback = 'animate' } = Astro.props as Props;
166
176
  }
167
177
  }
168
178
 
179
+ // Simulate scroll behavior of Safari and
180
+ // Chromium based browsers (Chrome, Edge, Opera, ...)
181
+ scrollTo({ left: 0, top: 0, behavior: 'instant' });
182
+
169
183
  if (state?.scrollY === 0 && location.hash) {
170
184
  const id = decodeURIComponent(location.hash.slice(1));
171
- state.scrollY = document.getElementById(id)?.offsetTop || 0;
172
- }
173
- if (state?.scrollY != null) {
174
- scrollTo(0, state.scrollY);
175
- // Overwrite erroneous updates by the scroll handler during transition
176
- persistState(state);
185
+ const elem = document.getElementById(id);
186
+ // prefer scrollIntoView() over scrollTo() because it takes scroll-padding into account
187
+ if (elem) {
188
+ state.scrollY = elem.offsetTop;
189
+ persistState(state); // first guess, later updated by scroll handler
190
+ elem.scrollIntoView(); // for Firefox, this should better be {behavior: 'instant'}
191
+ }
192
+ } else if (state && state.scrollY !== 0) {
193
+ scrollTo(0, state.scrollY); // usings default scrollBehavior
177
194
  }
178
195
 
179
- triggerEvent('astro:beforeload');
196
+ triggerEvent('astro:after-swap');
180
197
  };
181
198
 
182
199
  // Wait on links to finish, to prevent FOUC
@@ -233,18 +250,20 @@ const { fallback = 'animate' } = Astro.props as Props;
233
250
  location.href = href;
234
251
  return;
235
252
  }
253
+ document.documentElement.dataset.astroTransition = dir;
236
254
  if (supportsViewTransitions) {
237
- finished = document.startViewTransition(() => updateDOM(dir, html, state)).finished;
255
+ finished = document.startViewTransition(() => updateDOM(html, state)).finished;
238
256
  } else {
239
- finished = updateDOM(dir, html, state, getFallback());
257
+ finished = updateDOM(html, state, getFallback());
240
258
  }
241
259
  try {
242
260
  await finished;
243
261
  } finally {
244
- document.documentElement.removeAttribute('data-astro-transition');
262
+ // skip this for the moment as it tends to stop fallback animations
263
+ // document.documentElement.removeAttribute('data-astro-transition');
245
264
  await runScripts();
246
265
  markScriptsExec();
247
- onload();
266
+ onPageLoad();
248
267
  }
249
268
  }
250
269
 
@@ -273,43 +292,69 @@ const { fallback = 'animate' } = Astro.props as Props;
273
292
  // that is going to another page within the same origin. Basically it determines
274
293
  // same-origin navigation, but omits special key combos for new tabs, etc.
275
294
  if (
276
- link &&
277
- link instanceof HTMLAnchorElement &&
278
- link.href &&
279
- (!link.target || link.target === '_self') &&
280
- link.origin === location.origin &&
281
- !(
282
- // Same page means same path and same query params
283
- (location.pathname === link.pathname && location.search === link.search)
284
- ) &&
285
- ev.button === 0 && // left clicks only
286
- !ev.metaKey && // new tab (mac)
287
- !ev.ctrlKey && // new tab (windows)
288
- !ev.altKey && // download
289
- !ev.shiftKey &&
290
- !ev.defaultPrevented &&
291
- transitionEnabledOnThisPage()
292
- ) {
293
- ev.preventDefault();
294
- navigate('forward', link.href, { index: currentHistoryIndex, scrollY: 0 });
295
- currentHistoryIndex++;
296
- const newState: State = { index: currentHistoryIndex, scrollY };
297
- persistState({ index: currentHistoryIndex - 1, scrollY });
298
- history.pushState(newState, '', link.href);
295
+ !link ||
296
+ !(link instanceof HTMLAnchorElement) ||
297
+ link.dataset.astroReload !== undefined ||
298
+ !link.href ||
299
+ (link.target && link.target !== '_self') ||
300
+ link.origin !== location.origin ||
301
+ ev.button !== 0 || // left clicks only
302
+ ev.metaKey || // new tab (mac)
303
+ ev.ctrlKey || // new tab (windows)
304
+ ev.altKey || // download
305
+ ev.shiftKey || // new window
306
+ ev.defaultPrevented ||
307
+ !transitionEnabledOnThisPage()
308
+ )
309
+ // No page transitions in these cases,
310
+ // Let the browser standard action handle this
311
+ return;
312
+
313
+ // We do not need to handle same page links because there are no page transitions
314
+ // Same page means same path and same query params (but different hash)
315
+ if (location.pathname === link.pathname && location.search === link.search) {
316
+ if (link.hash) {
317
+ // The browser default action will handle navigations with hash fragments
318
+ return;
319
+ } else {
320
+ // Special case: self link without hash
321
+ // If handed to the browser it will reload the page
322
+ // But we want to handle it like any other same page navigation
323
+ // So we scroll to the top of the page but do not start page transitions
324
+ ev.preventDefault();
325
+ persistState({ ...history.state, scrollY });
326
+ scrollTo({ left: 0, top: 0, behavior: 'instant' });
327
+ if (location.hash) {
328
+ // last target was different
329
+ const newState: State = { index: ++currentHistoryIndex, scrollY: 0 };
330
+ history.pushState(newState, '', link.href);
331
+ }
332
+ return;
333
+ }
299
334
  }
335
+
336
+ // these are the cases we will handle: same origin, different page
337
+ ev.preventDefault();
338
+ navigate('forward', link.href, { index: ++currentHistoryIndex, scrollY: 0 });
339
+ const newState: State = { index: currentHistoryIndex, scrollY };
340
+ persistState({ index: currentHistoryIndex - 1, scrollY });
341
+ history.pushState(newState, '', link.href);
300
342
  });
343
+
301
344
  addEventListener('popstate', (ev) => {
302
- if (!transitionEnabledOnThisPage()) {
345
+ if (!transitionEnabledOnThisPage() && ev.state) {
303
346
  // The current page doesn't haven't View Transitions,
304
347
  // respect that with a full page reload
348
+ // -- but only for transition managed by us (ev.state is set)
305
349
  location.reload();
306
350
  return;
307
351
  }
308
352
 
309
- // hash change creates no state.
353
+ // History entries without state are created by the browser (e.g. for hash links)
354
+ // Our view transition entries always have state.
355
+ // Just ignore stateless entries.
356
+ // The browser will handle navigation fine without our help
310
357
  if (ev.state === null) {
311
- persistState({ index: currentHistoryIndex, scrollY });
312
- ev.preventDefault();
313
358
  return;
314
359
  }
315
360
 
@@ -338,17 +383,17 @@ const { fallback = 'animate' } = Astro.props as Props;
338
383
  { passive: true, capture: true }
339
384
  );
340
385
  });
341
- addEventListener('load', onload);
386
+ addEventListener('load', onPageLoad);
342
387
  // There's not a good way to record scroll position before a back button.
343
- // So the way we do it is by listening to scroll and just continuously recording it.
344
- addEventListener(
345
- 'scroll',
346
- throttle(() => {
347
- if (history.state) {
348
- persistState({ ...history.state, scrollY });
349
- }
350
- }, 300),
351
- { passive: true }
352
- );
388
+ // So the way we do it is by listening to scrollend if supported, and if not continuously record the scroll position.
389
+ const updateState = () => {
390
+ // only update history entries that are managed by us
391
+ // leave other entries alone and do not accidently add state.
392
+ if (history.state) {
393
+ persistState({ ...history.state, scrollY });
394
+ }
395
+ }
396
+ if ('onscrollend' in window) addEventListener('scrollend', updateState);
397
+ else addEventListener('scroll', throttle(updateState, 300));
353
398
  }
354
399
  </script>
@@ -34,10 +34,4 @@ export const themes = {
34
34
  'solarized-light': () => import('shiki/themes/solarized-light.json').then(mod => mod.default),
35
35
  'vitesse-dark': () => import('shiki/themes/vitesse-dark.json').then(mod => mod.default),
36
36
  'vitesse-light': () => import('shiki/themes/vitesse-light.json').then(mod => mod.default),
37
- // old theme names for compat
38
- 'material-darker': () => import('shiki/themes/material-theme-darker').then(mod => mod.default),
39
- 'material-default': () => import('shiki/themes/material-theme').then(mod => mod.default),
40
- 'material-lighter': () => import('shiki/themes/material-theme-lighter').then(mod => mod.default),
41
- 'material-ocean': () => import('shiki/themes/material-theme-ocean').then(mod => mod.default),
42
- 'material-palenight': () => import('shiki/themes/material-theme-palenight').then(mod => mod.default),
43
37
  };
@@ -14,25 +14,6 @@ declare module 'astro:content' {
14
14
  type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
15
15
  export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
16
16
 
17
- // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
18
- /**
19
- * @deprecated
20
- * `astro:content` no longer provide `image()`.
21
- *
22
- * Please use it through `schema`, like such:
23
- * ```ts
24
- * import { defineCollection, z } from "astro:content";
25
- *
26
- * defineCollection({
27
- * schema: ({ image }) =>
28
- * z.object({
29
- * image: image(),
30
- * }),
31
- * });
32
- * ```
33
- */
34
- export const image: never;
35
-
36
17
  // This needs to be in sync with ImageMetadata
37
18
  export type ImageFunction = () => import('astro/zod').ZodObject<{
38
19
  src: import('astro/zod').ZodString;
@@ -53,12 +34,9 @@ declare module 'astro:content' {
53
34
 
54
35
  type BaseSchemaWithoutEffects =
55
36
  | import('astro/zod').AnyZodObject
56
- | import('astro/zod').ZodUnion<import('astro/zod').AnyZodObject[]>
37
+ | import('astro/zod').ZodUnion<[BaseSchemaWithoutEffects, ...BaseSchemaWithoutEffects[]]>
57
38
  | import('astro/zod').ZodDiscriminatedUnion<string, import('astro/zod').AnyZodObject[]>
58
- | import('astro/zod').ZodIntersection<
59
- import('astro/zod').AnyZodObject,
60
- import('astro/zod').AnyZodObject
61
- >;
39
+ | import('astro/zod').ZodIntersection<BaseSchemaWithoutEffects, BaseSchemaWithoutEffects>;
62
40
 
63
41
  type BaseSchema =
64
42
  | BaseSchemaWithoutEffects
@@ -14,8 +14,8 @@ import type { PageBuildData } from '../core/build/types';
14
14
  import type { AstroConfigType } from '../core/config';
15
15
  import type { AstroTimer } from '../core/config/timer';
16
16
  import type { AstroCookies } from '../core/cookies';
17
- import type { LogOptions, LoggerLevel } from '../core/logger/core';
18
- import type { AstroIntegrationLogger } from '../core/logger/core';
17
+ import type { ResponseWithEncoding } from '../core/endpoint/index.js';
18
+ import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger/core';
19
19
  import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
20
20
  import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
21
21
  export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
@@ -47,7 +47,7 @@ export interface TransitionDirectionalAnimations {
47
47
  forwards: TransitionAnimationPair;
48
48
  backwards: TransitionAnimationPair;
49
49
  }
50
- export type TransitionAnimationValue = 'morph' | 'slide' | 'fade' | TransitionDirectionalAnimations;
50
+ export type TransitionAnimationValue = 'initial' | 'slide' | 'fade' | 'none' | TransitionDirectionalAnimations;
51
51
  export interface AstroClientDirectives {
52
52
  }
53
53
  export interface AstroBuiltinAttributes {
@@ -55,7 +55,7 @@ export interface AstroBuiltinAttributes {
55
55
  'set:html'?: any;
56
56
  'set:text'?: any;
57
57
  'is:raw'?: boolean;
58
- 'transition:animate'?: 'morph' | 'slide' | 'fade' | TransitionDirectionalAnimations;
58
+ 'transition:animate'?: TransitionAnimationValue;
59
59
  'transition:name'?: string;
60
60
  'transition:persist'?: boolean | string;
61
61
  }
@@ -63,14 +63,10 @@ export interface AstroDefineVarsAttribute {
63
63
  'define:vars'?: any;
64
64
  }
65
65
  export interface AstroStyleAttributes {
66
- /** @deprecated Use `is:global` instead */
67
- global?: boolean;
68
66
  'is:global'?: boolean;
69
67
  'is:inline'?: boolean;
70
68
  }
71
69
  export interface AstroScriptAttributes {
72
- /** @deprecated Hoist is now the default behavior */
73
- hoist?: boolean;
74
70
  'is:inline'?: boolean;
75
71
  }
76
72
  export interface AstroComponentMetadata {
@@ -540,7 +536,7 @@ export interface AstroUserConfig {
540
536
  * @docs
541
537
  * @name scopedStyleStrategy
542
538
  * @type {('where' | 'class' | 'attribute')}
543
- * @default `'where'`
539
+ * @default `'attribute'`
544
540
  * @version 2.4
545
541
  * @description
546
542
  *
@@ -551,7 +547,7 @@ export interface AstroUserConfig {
551
547
  *
552
548
  * Using `'class'` is helpful when you want to ensure that element selectors within an Astro component override global style defaults (e.g. from a global stylesheet).
553
549
  * Using `'where'` gives you more control over specifity, but requires that you use higher-specifity selectors, layers, and other tools to control which selectors are applied.
554
- * Using `'attribute'` is useful in case there's manipulation of the class attributes, so the styling emitted by Astro doesn't go in conflict with the user's business logic.
550
+ * Using 'attribute' is useful when you are manipulating the `class` attribute of elements and need to avoid conflicts between your own styling logic and Astro's application of styles.
555
551
  */
556
552
  scopedStyleStrategy?: 'where' | 'class' | 'attribute';
557
553
  /**
@@ -787,22 +783,12 @@ export interface AstroUserConfig {
787
783
  * @name build.split
788
784
  * @type {boolean}
789
785
  * @default `false`
790
- * @version 2.7.0
786
+ * @deprecated Deprecated since version 3.0.
791
787
  * @description
792
- * Defines how the SSR code should be bundled when built.
788
+ * The build config option `build.split` has been replaced by the adapter configuration option [`functionPerRoute`](/en/reference/adapter-reference/#functionperroute).
793
789
  *
794
- * When `split` is `true`, Astro will emit a file for each page.
795
- * Each file emitted will render only one page. The pages will be emitted
796
- * inside a `dist/pages/` directory, and the emitted files will keep the same file paths
797
- * of the `src/pages` directory.
790
+ * Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `functionPerRoute` to define how your SSR code is bundled.
798
791
  *
799
- * ```js
800
- * {
801
- * build: {
802
- * split: true
803
- * }
804
- * }
805
- * ```
806
792
  */
807
793
  split?: boolean;
808
794
  /**
@@ -810,19 +796,11 @@ export interface AstroUserConfig {
810
796
  * @name build.excludeMiddleware
811
797
  * @type {boolean}
812
798
  * @default `false`
813
- * @version 2.8.0
799
+ * @deprecated Deprecated since version 3.0.
814
800
  * @description
815
- * Defines whether or not any SSR middleware code will be bundled when built.
816
- *
817
- * When enabled, middleware code is not bundled and imported by all pages during the build. To instead execute and import middleware code manually, set `build.excludeMiddleware: true`:
801
+ * The build config option `build.excludeMiddleware` has been replaced by the adapter configuration option [`edgeMiddleware`](/en/reference/adapter-reference/#edgemiddleware).
818
802
  *
819
- * ```js
820
- * {
821
- * build: {
822
- * excludeMiddleware: true
823
- * }
824
- * }
825
- * ```
803
+ * Please see your [SSR adapter's documentation](/en/guides/integrations-guide/#official-integrations) for using `edgeMiddleware` to define whether or not any SSR middleware code will be bundled when built.
826
804
  */
827
805
  excludeMiddleware?: boolean;
828
806
  };
@@ -1004,6 +982,7 @@ export interface AstroUserConfig {
1004
982
  * @name markdown.drafts
1005
983
  * @type {boolean}
1006
984
  * @default `false`
985
+ * @deprecated Deprecated since version 3.0. Use content collections instead.
1007
986
  * @description
1008
987
  * Control whether Markdown draft pages should be included in the build.
1009
988
  *
@@ -1142,7 +1121,7 @@ export interface AstroUserConfig {
1142
1121
  * @name Integrations
1143
1122
  * @description
1144
1123
  *
1145
- * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown and Turbolinks).
1124
+ * Extend Astro with custom integrations. Integrations are your one-stop-shop for adding framework support (like Solid.js), new features (like sitemaps), and new libraries (like Partytown).
1146
1125
  *
1147
1126
  * Read our [Integrations Guide](https://docs.astro.build/en/guides/integrations-guide/) for help getting started with Astro Integrations.
1148
1127
  *
@@ -1208,26 +1187,6 @@ export interface AstroUserConfig {
1208
1187
  * These flags are not guaranteed to be stable.
1209
1188
  */
1210
1189
  experimental?: {
1211
- /**
1212
- * @docs
1213
- * @name experimental.viewTransitions
1214
- * @type {boolean}
1215
- * @default `false`
1216
- * @version 2.9.0
1217
- * @description
1218
- * Enable experimental support for the `<ViewTransitions / >` component. With this enabled
1219
- * you can opt-in to [view transitions](https://docs.astro.build/en/guides/view-transitions/) on a per-page basis using this component
1220
- * and enable animations with the `transition:animate` directive.
1221
- *
1222
- * ```js
1223
- * {
1224
- * experimental: {
1225
- * viewTransitions: true,
1226
- * },
1227
- * }
1228
- * ```
1229
- */
1230
- viewTransitions?: boolean;
1231
1190
  /**
1232
1191
  * @docs
1233
1192
  * @name experimental.optimizeHoistedScript
@@ -1250,26 +1209,6 @@ export interface AstroUserConfig {
1250
1209
  */
1251
1210
  optimizeHoistedScript?: boolean;
1252
1211
  };
1253
- /** @deprecated - Use "integrations" instead. Run Astro to learn more about migrating. */
1254
- renderers?: never;
1255
- /** @deprecated `projectRoot` has been renamed to `root` */
1256
- projectRoot?: never;
1257
- /** @deprecated `src` has been renamed to `srcDir` */
1258
- src?: never;
1259
- /** @deprecated `pages` has been removed. It is no longer configurable. */
1260
- pages?: never;
1261
- /** @deprecated `public` has been renamed to `publicDir` */
1262
- public?: never;
1263
- /** @deprecated `dist` has been renamed to `outDir` */
1264
- dist?: never;
1265
- /** @deprecated `styleOptions` has been renamed to `style` */
1266
- styleOptions?: never;
1267
- /** @deprecated `markdownOptions` has been renamed to `markdown` */
1268
- markdownOptions?: never;
1269
- /** @deprecated `buildOptions` has been renamed to `build` */
1270
- buildOptions?: never;
1271
- /** @deprecated `devOptions` has been renamed to `server` */
1272
- devOptions?: never;
1273
1212
  }
1274
1213
  /**
1275
1214
  * IDs for different stages of JS script injection:
@@ -1329,7 +1268,7 @@ export interface AstroInlineOnlyConfig {
1329
1268
  /**
1330
1269
  * @internal for testing only, use `logLevel` instead.
1331
1270
  */
1332
- logging?: LogOptions;
1271
+ logger?: Logger;
1333
1272
  }
1334
1273
  export type ContentEntryModule = {
1335
1274
  id: string;
@@ -1430,6 +1369,10 @@ export interface ComponentInstance {
1430
1369
  default: AstroComponentFactory;
1431
1370
  css?: string[];
1432
1371
  prerender?: boolean;
1372
+ /**
1373
+ * Only used for logging if deprecated drafts feature is used
1374
+ */
1375
+ frontmatter?: Record<string, any>;
1433
1376
  getStaticPaths?: (options: GetStaticPathsOptions) => GetStaticPathsResult;
1434
1377
  }
1435
1378
  export interface AstroInstance {
@@ -1788,10 +1731,11 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
1788
1731
  * ```
1789
1732
  */
1790
1733
  locals: App.Locals;
1734
+ ResponseWithEncoding: typeof ResponseWithEncoding;
1791
1735
  }
1792
1736
  export type EndpointOutput = {
1793
1737
  body: Body;
1794
- encoding?: Exclude<BufferEncoding, 'binary'>;
1738
+ encoding?: BufferEncoding;
1795
1739
  } | {
1796
1740
  body: Uint8Array;
1797
1741
  encoding: 'binary';
@@ -1904,7 +1848,7 @@ export type AstroMiddlewareInstance<R> = {
1904
1848
  };
1905
1849
  export interface AstroPluginOptions {
1906
1850
  settings: AstroSettings;
1907
- logging: LogOptions;
1851
+ logger: Logger;
1908
1852
  }
1909
1853
  export type RouteType = 'page' | 'endpoint' | 'redirect';
1910
1854
  export interface RoutePart {
@@ -1,4 +1,4 @@
1
- import type { StaticBuildOptions } from '../../core/build/types.js';
1
+ import type { BuildPipeline } from '../../core/build/buildPipeline';
2
2
  import type { ImageTransform } from '../types.js';
3
3
  interface GenerationDataUncached {
4
4
  cached: false;
@@ -11,7 +11,7 @@ interface GenerationDataCached {
11
11
  cached: true;
12
12
  }
13
13
  type GenerationData = GenerationDataUncached | GenerationDataCached;
14
- export declare function generateImage(buildOpts: StaticBuildOptions, options: ImageTransform, filepath: string): Promise<GenerationData | undefined>;
14
+ export declare function generateImage(pipeline: BuildPipeline, options: ImageTransform, filepath: string): Promise<GenerationData | undefined>;
15
15
  export declare function getStaticImageList(): Iterable<[
16
16
  string,
17
17
  {
@@ -1,30 +1,30 @@
1
1
  import fs, { readFileSync } from "node:fs";
2
2
  import { basename, join } from "node:path/posix";
3
- import { warn } from "../../core/logger/core.js";
4
3
  import { prependForwardSlash } from "../../core/path.js";
5
4
  import { isServerLikeOutput } from "../../prerender/utils.js";
6
5
  import { getConfiguredImageService, isESMImportedImage } from "../internal.js";
7
6
  import { loadRemoteImage } from "./remote.js";
8
- async function generateImage(buildOpts, options, filepath) {
7
+ async function generateImage(pipeline, options, filepath) {
8
+ const config = pipeline.getConfig();
9
+ const logger = pipeline.getLogger();
9
10
  let useCache = true;
10
- const assetsCacheDir = new URL("assets/", buildOpts.settings.config.cacheDir);
11
+ const assetsCacheDir = new URL("assets/", config.cacheDir);
11
12
  try {
12
13
  await fs.promises.mkdir(assetsCacheDir, { recursive: true });
13
14
  } catch (err) {
14
- warn(
15
- buildOpts.logging,
15
+ logger.warn(
16
16
  "astro:assets",
17
17
  `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${err}`
18
18
  );
19
19
  useCache = false;
20
20
  }
21
21
  let serverRoot, clientRoot;
22
- if (isServerLikeOutput(buildOpts.settings.config)) {
23
- serverRoot = buildOpts.settings.config.build.server;
24
- clientRoot = buildOpts.settings.config.build.client;
22
+ if (isServerLikeOutput(config)) {
23
+ serverRoot = config.build.server;
24
+ clientRoot = config.build.client;
25
25
  } else {
26
- serverRoot = buildOpts.settings.config.outDir;
27
- clientRoot = buildOpts.settings.config.outDir;
26
+ serverRoot = config.outDir;
27
+ clientRoot = config.outDir;
28
28
  }
29
29
  const isLocalImage = isESMImportedImage(options.src);
30
30
  const finalFileURL = new URL("." + filepath, clientRoot);
@@ -61,9 +61,7 @@ async function generateImage(buildOpts, options, filepath) {
61
61
  if (isLocalImage) {
62
62
  imageData = await fs.promises.readFile(
63
63
  new URL(
64
- "." + prependForwardSlash(
65
- join(buildOpts.settings.config.build.assets, basename(originalImagePath))
66
- ),
64
+ "." + prependForwardSlash(join(config.build.assets, basename(originalImagePath))),
67
65
  serverRoot
68
66
  )
69
67
  );
@@ -73,11 +71,7 @@ async function generateImage(buildOpts, options, filepath) {
73
71
  imageData = remoteImage.data;
74
72
  }
75
73
  const imageService = await getConfiguredImageService();
76
- resultData.data = (await imageService.transform(
77
- imageData,
78
- { ...options, src: originalImagePath },
79
- buildOpts.settings.config.image
80
- )).data;
74
+ resultData.data = (await imageService.transform(imageData, { ...options, src: originalImagePath }, config.image)).data;
81
75
  try {
82
76
  if (useCache) {
83
77
  if (isLocalImage) {
@@ -93,8 +87,7 @@ async function generateImage(buildOpts, options, filepath) {
93
87
  }
94
88
  }
95
89
  } catch (e) {
96
- warn(
97
- buildOpts.logging,
90
+ logger.warn(
98
91
  "astro:assets",
99
92
  `An error was encountered while creating the cache directory. Proceeding without caching. Error: ${e}`
100
93
  );
@@ -1,7 +1,7 @@
1
- import mime from "mime/lite.js";
2
- import { etag } from "./utils/etag.js";
3
1
  import { isRemotePath } from "@astrojs/internal-helpers/path";
2
+ import mime from "mime/lite.js";
4
3
  import { getConfiguredImageService, isRemoteAllowed } from "./internal.js";
4
+ import { etag } from "./utils/etag.js";
5
5
  import { imageConfig } from "astro:assets";
6
6
  async function loadRemoteImage(src) {
7
7
  try {