astro 3.0.0-beta.2 → 3.0.0-beta.4

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 (117) hide show
  1. package/astro.js +5 -1
  2. package/client.d.ts +450 -8
  3. package/components/Code.astro +2 -2
  4. package/components/ViewTransitions.astro +49 -3
  5. package/config.d.ts +7 -0
  6. package/config.mjs +7 -0
  7. package/content-types.template.d.ts +3 -1
  8. package/dist/@types/astro.d.ts +110 -40
  9. package/dist/assets/{generate.d.ts → build/generate.d.ts} +2 -2
  10. package/dist/assets/build/generate.js +122 -0
  11. package/dist/assets/build/remote.d.ts +9 -0
  12. package/dist/assets/build/remote.js +42 -0
  13. package/dist/assets/image-endpoint.js +9 -11
  14. package/dist/assets/internal.d.ts +5 -3
  15. package/dist/assets/internal.js +28 -7
  16. package/dist/assets/services/service.d.ts +15 -8
  17. package/dist/assets/services/service.js +19 -10
  18. package/dist/assets/services/sharp.js +2 -1
  19. package/dist/assets/types.d.ts +9 -2
  20. package/dist/assets/utils/remotePattern.d.ts +11 -0
  21. package/dist/assets/utils/remotePattern.js +46 -0
  22. package/dist/assets/utils/transformToPath.js +4 -5
  23. package/dist/assets/vite-plugin-assets.js +2 -19
  24. package/dist/cli/add/index.js +28 -3
  25. package/dist/cli/build/index.js +1 -3
  26. package/dist/cli/check/index.js +1 -1
  27. package/dist/cli/flags.js +0 -3
  28. package/dist/cli/sync/index.js +1 -1
  29. package/dist/content/runtime.js +1 -1
  30. package/dist/content/types-generator.js +1 -2
  31. package/dist/content/utils.d.ts +2 -2
  32. package/dist/content/utils.js +3 -8
  33. package/dist/content/vite-plugin-content-imports.js +5 -13
  34. package/dist/core/app/index.js +23 -19
  35. package/dist/core/app/node.d.ts +2 -1
  36. package/dist/core/app/node.js +63 -46
  37. package/dist/core/app/ssrPipeline.d.ts +0 -1
  38. package/dist/core/app/ssrPipeline.js +2 -2
  39. package/dist/core/build/buildPipeline.d.ts +42 -0
  40. package/dist/core/build/buildPipeline.js +167 -0
  41. package/dist/core/build/generate.js +106 -113
  42. package/dist/core/build/index.d.ts +10 -2
  43. package/dist/core/build/index.js +2 -2
  44. package/dist/core/build/internal.d.ts +2 -1
  45. package/dist/core/build/internal.js +0 -8
  46. package/dist/core/build/plugins/index.js +2 -0
  47. package/dist/core/build/plugins/plugin-manifest.d.ts +16 -0
  48. package/dist/core/build/plugins/plugin-manifest.js +202 -0
  49. package/dist/core/build/plugins/plugin-middleware.js +1 -1
  50. package/dist/core/build/plugins/plugin-pages.d.ts +2 -0
  51. package/dist/core/build/plugins/plugin-pages.js +12 -5
  52. package/dist/core/build/plugins/plugin-prerender.js +1 -1
  53. package/dist/core/build/plugins/plugin-ssr.d.ts +3 -11
  54. package/dist/core/build/plugins/plugin-ssr.js +8 -167
  55. package/dist/core/build/static-build.js +21 -8
  56. package/dist/core/compile/compile.js +1 -1
  57. package/dist/core/config/config.js +1 -2
  58. package/dist/core/config/index.d.ts +1 -1
  59. package/dist/core/config/schema.d.ts +105 -16
  60. package/dist/core/config/schema.js +18 -4
  61. package/dist/core/config/tsconfig.js +17 -2
  62. package/dist/core/constants.js +1 -1
  63. package/dist/core/create-vite.js +9 -1
  64. package/dist/core/dev/container.js +1 -3
  65. package/dist/core/dev/dev.d.ts +6 -1
  66. package/dist/core/dev/dev.js +1 -1
  67. package/dist/core/errors/errors-data.d.ts +40 -14
  68. package/dist/core/errors/errors-data.js +8 -1
  69. package/dist/core/index.d.ts +17 -0
  70. package/dist/core/index.js +12 -0
  71. package/dist/core/logger/core.d.ts +4 -4
  72. package/dist/core/messages.js +2 -2
  73. package/dist/core/middleware/namespace.d.ts +1 -0
  74. package/dist/core/middleware/namespace.js +5 -0
  75. package/dist/core/pipeline.d.ts +5 -6
  76. package/dist/core/pipeline.js +15 -7
  77. package/dist/core/polyfill.js +48 -1
  78. package/dist/core/preview/index.d.ts +7 -2
  79. package/dist/core/render/environment.d.ts +1 -6
  80. package/dist/core/render/index.d.ts +4 -5
  81. package/dist/core/render/index.js +1 -2
  82. package/dist/core/render/renderer.d.ts +1 -2
  83. package/dist/core/render/renderer.js +1 -6
  84. package/dist/core/routing/manifest/create.js +6 -1
  85. package/dist/core/sync/index.d.ts +8 -3
  86. package/dist/core/sync/index.js +2 -2
  87. package/dist/prerender/routing.d.ts +3 -3
  88. package/dist/prerender/routing.js +5 -5
  89. package/dist/prerender/utils.d.ts +4 -0
  90. package/dist/prerender/utils.js +10 -0
  91. package/dist/runtime/compiler/index.d.ts +1 -0
  92. package/dist/runtime/compiler/index.js +36 -0
  93. package/dist/template/4xx.js +34 -4
  94. package/dist/vite-plugin-astro-server/devPipeline.d.ts +24 -0
  95. package/dist/vite-plugin-astro-server/devPipeline.js +98 -0
  96. package/dist/vite-plugin-astro-server/environment.d.ts +2 -2
  97. package/dist/vite-plugin-astro-server/environment.js +1 -6
  98. package/dist/vite-plugin-astro-server/index.d.ts +3 -3
  99. package/dist/vite-plugin-astro-server/index.js +4 -6
  100. package/dist/vite-plugin-astro-server/plugin.js +8 -10
  101. package/dist/vite-plugin-astro-server/request.d.ts +3 -3
  102. package/dist/vite-plugin-astro-server/request.js +7 -8
  103. package/dist/vite-plugin-astro-server/route.d.ts +4 -4
  104. package/dist/vite-plugin-astro-server/route.js +58 -89
  105. package/dist/vite-plugin-inject-env-ts/index.js +1 -20
  106. package/dist/vite-plugin-integrations-container/index.js +2 -2
  107. package/dist/vite-plugin-markdown/index.js +3 -4
  108. package/dist/vite-plugin-mdx/tag.js +2 -2
  109. package/env.d.ts +2 -2
  110. package/index.d.ts +2 -0
  111. package/package.json +23 -20
  112. package/tsconfigs/base.json +0 -5
  113. package/client-base.d.ts +0 -425
  114. package/client-image.d.ts +0 -41
  115. package/dist/assets/generate.js +0 -94
  116. package/dist/template/css.d.ts +0 -6
  117. package/dist/template/css.js +0 -46
package/astro.js CHANGED
@@ -16,11 +16,15 @@ const CI_INSTRUCTIONS = {
16
16
  const engines = '>=18.14.1';
17
17
  const skipSemverCheckIfAbove = 19;
18
18
 
19
+ // HACK (2023-08-18) Stackblitz does not support Node 18 yet, so we'll fake Node 16 support for some time until it's supported
20
+ // TODO: Remove when Node 18 is supported on Stackblitz
21
+ const isStackblitz = process.env.SHELL === '/bin/jsh' && process.versions.webcontainer != null;
22
+
19
23
  /** `astro *` */
20
24
  async function main() {
21
25
  const version = process.versions.node;
22
26
  // Fast-path for higher Node.js versions
23
- if ((parseInt(version) || 0) <= skipSemverCheckIfAbove) {
27
+ if (!isStackblitz && (parseInt(version) || 0) <= skipSemverCheckIfAbove) {
24
28
  try {
25
29
  const semver = await import('semver');
26
30
  if (!semver.satisfies(version, engines)) {
package/client.d.ts CHANGED
@@ -1,31 +1,473 @@
1
- /// <reference path="./client-base.d.ts" />
1
+ /// <reference path="./import-meta.d.ts" />
2
2
 
3
- // images
3
+ // eslint-disable-next-line @typescript-eslint/no-namespace
4
+ declare namespace App {
5
+ // eslint-disable-next-line @typescript-eslint/no-empty-interface
6
+ export interface Locals {}
7
+ }
8
+
9
+ interface ImportMetaEnv {
10
+ /**
11
+ * The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro.
12
+ */
13
+ readonly ASSETS_PREFIX: string;
14
+ /**
15
+ * This is set to the site option specified in your project’s Astro config file.
16
+ */
17
+ readonly SITE: string;
18
+ }
19
+
20
+ interface ImportMeta {
21
+ /**
22
+ * Astro and Vite expose environment variables through `import.meta.env`. For a complete list of the environment variables available, see the two references below.
23
+ *
24
+ * - [Astro reference](https://docs.astro.build/en/guides/environment-variables/#default-environment-variables)
25
+ * - [Vite reference](https://vitejs.dev/guide/env-and-mode.html#env-variables)
26
+ */
27
+ readonly env: ImportMetaEnv;
28
+ }
29
+
30
+ declare module 'astro:assets' {
31
+ // Exporting things one by one is a bit cumbersome, not sure if there's a better way - erika, 2023-02-03
32
+ type AstroAssets = {
33
+ // getImage's type here is different from the internal function since the Vite module implicitly pass the service config
34
+ /**
35
+ * Get an optimized image and the necessary attributes to render it.
36
+ *
37
+ * **Example**
38
+ * ```astro
39
+ * ---
40
+ * import { getImage } from 'astro:assets';
41
+ * import originalImage from '../assets/image.png';
42
+ *
43
+ * const optimizedImage = await getImage({src: originalImage, width: 1280 });
44
+ * ---
45
+ * <img src={optimizedImage.src} {...optimizedImage.attributes} />
46
+ * ```
47
+ *
48
+ * This is functionally equivalent to using the `<Image />` component, as the component calls this function internally.
49
+ */
50
+ getImage: (
51
+ options:
52
+ | import('./dist/assets/types.js').ImageTransform
53
+ | import('./dist/assets/types.js').UnresolvedImageTransform
54
+ ) => Promise<import('./dist/assets/types.js').GetImageResult>;
55
+ getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
56
+ Image: typeof import('./components/Image.astro').default;
57
+ };
58
+
59
+ type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
60
+ type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
61
+ type ImgAttributes = WithRequired<
62
+ Omit<import('./types').HTMLAttributes<'img'>, 'src' | 'width' | 'height'>,
63
+ 'alt'
64
+ >;
65
+
66
+ export type LocalImageProps = Simplify<
67
+ import('./dist/assets/types.js').LocalImageProps<ImgAttributes>
68
+ >;
69
+ export type RemoteImageProps = Simplify<
70
+ import('./dist/assets/types.js').RemoteImageProps<ImgAttributes>
71
+ >;
72
+ export const { getImage, getConfiguredImageService, Image }: AstroAssets;
73
+ }
74
+
75
+ type InputFormat = import('./dist/assets/types.js').ImageInputFormat;
76
+
77
+ interface ImageMetadata {
78
+ src: string;
79
+ width: number;
80
+ height: number;
81
+ format: InputFormat;
82
+ }
83
+
84
+ declare module '*.gif' {
85
+ const metadata: ImageMetadata;
86
+ export default metadata;
87
+ }
88
+ declare module '*.jpeg' {
89
+ const metadata: ImageMetadata;
90
+ export default metadata;
91
+ }
4
92
  declare module '*.jpg' {
93
+ const metadata: ImageMetadata;
94
+ export default metadata;
95
+ }
96
+ declare module '*.png' {
97
+ const metadata: ImageMetadata;
98
+ export default metadata;
99
+ }
100
+ declare module '*.tiff' {
101
+ const metadata: ImageMetadata;
102
+ export default metadata;
103
+ }
104
+ declare module '*.webp' {
105
+ const metadata: ImageMetadata;
106
+ export default metadata;
107
+ }
108
+ declare module '*.svg' {
109
+ const metadata: ImageMetadata;
110
+ export default metadata;
111
+ }
112
+
113
+ declare module 'astro:transitions' {
114
+ type TransitionModule = typeof import('./dist/transitions/index.js');
115
+ export const slide: TransitionModule['slide'];
116
+ export const fade: TransitionModule['fade'];
117
+
118
+ type ViewTransitionsModule = typeof import('./components/ViewTransitions.astro');
119
+ export const ViewTransitions: ViewTransitionsModule['default'];
120
+ }
121
+
122
+ declare module 'astro:middleware' {
123
+ export * from 'astro/middleware/namespace';
124
+ }
125
+
126
+ declare module 'astro:components' {
127
+ export * from 'astro/components';
128
+ }
129
+
130
+ type MD = import('./dist/@types/astro').MarkdownInstance<Record<string, any>>;
131
+ interface ExportedMarkdownModuleEntities {
132
+ frontmatter: MD['frontmatter'];
133
+ file: MD['file'];
134
+ url: MD['url'];
135
+ getHeadings: MD['getHeadings'];
136
+ /** @deprecated Renamed to `getHeadings()` */
137
+ getHeaders: () => void;
138
+ Content: MD['Content'];
139
+ rawContent: MD['rawContent'];
140
+ compiledContent: MD['compiledContent'];
141
+ load: MD['default'];
142
+ }
143
+
144
+ declare module '*.md' {
145
+ const { load }: ExportedMarkdownModuleEntities;
146
+ export const {
147
+ frontmatter,
148
+ file,
149
+ url,
150
+ getHeadings,
151
+ getHeaders,
152
+ Content,
153
+ rawContent,
154
+ compiledContent,
155
+ }: ExportedMarkdownModuleEntities;
156
+ export default load;
157
+ }
158
+
159
+ declare module '*.markdown' {
160
+ const { load }: ExportedMarkdownModuleEntities;
161
+ export const {
162
+ frontmatter,
163
+ file,
164
+ url,
165
+ getHeadings,
166
+ getHeaders,
167
+ Content,
168
+ rawContent,
169
+ compiledContent,
170
+ }: ExportedMarkdownModuleEntities;
171
+ export default load;
172
+ }
173
+
174
+ declare module '*.mkdn' {
175
+ const { load }: ExportedMarkdownModuleEntities;
176
+ export const {
177
+ frontmatter,
178
+ file,
179
+ url,
180
+ getHeadings,
181
+ getHeaders,
182
+ Content,
183
+ rawContent,
184
+ compiledContent,
185
+ }: ExportedMarkdownModuleEntities;
186
+ export default load;
187
+ }
188
+
189
+ declare module '*.mkd' {
190
+ const { load }: ExportedMarkdownModuleEntities;
191
+ export const {
192
+ frontmatter,
193
+ file,
194
+ url,
195
+ getHeadings,
196
+ getHeaders,
197
+ Content,
198
+ rawContent,
199
+ compiledContent,
200
+ }: ExportedMarkdownModuleEntities;
201
+ export default load;
202
+ }
203
+
204
+ declare module '*.mdwn' {
205
+ const { load }: ExportedMarkdownModuleEntities;
206
+ export const {
207
+ frontmatter,
208
+ file,
209
+ url,
210
+ getHeadings,
211
+ getHeaders,
212
+ Content,
213
+ rawContent,
214
+ compiledContent,
215
+ }: ExportedMarkdownModuleEntities;
216
+ export default load;
217
+ }
218
+
219
+ declare module '*.mdown' {
220
+ const { load }: ExportedMarkdownModuleEntities;
221
+ export const {
222
+ frontmatter,
223
+ file,
224
+ url,
225
+ getHeadings,
226
+ getHeaders,
227
+ Content,
228
+ rawContent,
229
+ compiledContent,
230
+ }: ExportedMarkdownModuleEntities;
231
+ export default load;
232
+ }
233
+
234
+ declare module '*.mdx' {
235
+ type MDX = import('./dist/@types/astro').MDXInstance<Record<string, any>>;
236
+
237
+ export const frontmatter: MDX['frontmatter'];
238
+ export const file: MDX['file'];
239
+ export const url: MDX['url'];
240
+ export const getHeadings: MDX['getHeadings'];
241
+ export const Content: MDX['Content'];
242
+
243
+ const load: MDX['default'];
244
+ export default load;
245
+ }
246
+
247
+ declare module 'astro:ssr-manifest' {
248
+ export const manifest: import('./dist/@types/astro').SSRManifest;
249
+ }
250
+
251
+ // Everything below are Vite's types (apart from image types, which are in `client.d.ts`)
252
+
253
+ // CSS modules
254
+ type CSSModuleClasses = { readonly [key: string]: string };
255
+
256
+ declare module '*.module.css' {
257
+ const classes: CSSModuleClasses;
258
+ export default classes;
259
+ }
260
+ declare module '*.module.scss' {
261
+ const classes: CSSModuleClasses;
262
+ export default classes;
263
+ }
264
+ declare module '*.module.sass' {
265
+ const classes: CSSModuleClasses;
266
+ export default classes;
267
+ }
268
+ declare module '*.module.less' {
269
+ const classes: CSSModuleClasses;
270
+ export default classes;
271
+ }
272
+ declare module '*.module.styl' {
273
+ const classes: CSSModuleClasses;
274
+ export default classes;
275
+ }
276
+ declare module '*.module.stylus' {
277
+ const classes: CSSModuleClasses;
278
+ export default classes;
279
+ }
280
+ declare module '*.module.pcss' {
281
+ const classes: CSSModuleClasses;
282
+ export default classes;
283
+ }
284
+ declare module '*.module.sss' {
285
+ const classes: CSSModuleClasses;
286
+ export default classes;
287
+ }
288
+
289
+ // CSS
290
+ declare module '*.css' {
291
+ const css: string;
292
+ export default css;
293
+ }
294
+ declare module '*.scss' {
295
+ const css: string;
296
+ export default css;
297
+ }
298
+ declare module '*.sass' {
299
+ const css: string;
300
+ export default css;
301
+ }
302
+ declare module '*.less' {
303
+ const css: string;
304
+ export default css;
305
+ }
306
+ declare module '*.styl' {
307
+ const css: string;
308
+ export default css;
309
+ }
310
+ declare module '*.stylus' {
311
+ const css: string;
312
+ export default css;
313
+ }
314
+ declare module '*.pcss' {
315
+ const css: string;
316
+ export default css;
317
+ }
318
+ declare module '*.sss' {
319
+ const css: string;
320
+ export default css;
321
+ }
322
+
323
+ // Built-in asset types
324
+ // see `src/node/constants.ts`
325
+
326
+ // images
327
+ declare module '*.jfif' {
5
328
  const src: string;
6
329
  export default src;
7
330
  }
8
- declare module '*.jpeg' {
331
+ declare module '*.pjpeg' {
9
332
  const src: string;
10
333
  export default src;
11
334
  }
12
- declare module '*.png' {
335
+ declare module '*.pjp' {
13
336
  const src: string;
14
337
  export default src;
15
338
  }
16
- declare module '*.gif' {
339
+ declare module '*.ico' {
17
340
  const src: string;
18
341
  export default src;
19
342
  }
20
- declare module '*.svg' {
343
+
344
+ // media
345
+ declare module '*.mp4' {
21
346
  const src: string;
22
347
  export default src;
23
348
  }
24
- declare module '*.webp' {
349
+ declare module '*.webm' {
350
+ const src: string;
351
+ export default src;
352
+ }
353
+ declare module '*.ogg' {
354
+ const src: string;
355
+ export default src;
356
+ }
357
+ declare module '*.mp3' {
358
+ const src: string;
359
+ export default src;
360
+ }
361
+ declare module '*.wav' {
362
+ const src: string;
363
+ export default src;
364
+ }
365
+ declare module '*.flac' {
366
+ const src: string;
367
+ export default src;
368
+ }
369
+ declare module '*.aac' {
25
370
  const src: string;
26
371
  export default src;
27
372
  }
28
- declare module '*.avif' {
373
+
374
+ declare module '*.opus' {
375
+ const src: string;
376
+ export default src;
377
+ }
378
+
379
+ // fonts
380
+ declare module '*.woff' {
381
+ const src: string;
382
+ export default src;
383
+ }
384
+ declare module '*.woff2' {
385
+ const src: string;
386
+ export default src;
387
+ }
388
+ declare module '*.eot' {
389
+ const src: string;
390
+ export default src;
391
+ }
392
+ declare module '*.ttf' {
393
+ const src: string;
394
+ export default src;
395
+ }
396
+ declare module '*.otf' {
397
+ const src: string;
398
+ export default src;
399
+ }
400
+
401
+ // other
402
+ declare module '*.webmanifest' {
403
+ const src: string;
404
+ export default src;
405
+ }
406
+ declare module '*.pdf' {
407
+ const src: string;
408
+ export default src;
409
+ }
410
+ declare module '*.txt' {
411
+ const src: string;
412
+ export default src;
413
+ }
414
+
415
+ // wasm?init
416
+ declare module '*.wasm?init' {
417
+ const initWasm: (options: WebAssembly.Imports) => Promise<WebAssembly.Instance>;
418
+ export default initWasm;
419
+ }
420
+
421
+ // web worker
422
+ declare module '*?worker' {
423
+ const workerConstructor: {
424
+ new (): Worker;
425
+ };
426
+ export default workerConstructor;
427
+ }
428
+
429
+ declare module '*?worker&inline' {
430
+ const workerConstructor: {
431
+ new (): Worker;
432
+ };
433
+ export default workerConstructor;
434
+ }
435
+
436
+ declare module '*?worker&url' {
437
+ const src: string;
438
+ export default src;
439
+ }
440
+
441
+ declare module '*?sharedworker' {
442
+ const sharedWorkerConstructor: {
443
+ new (): SharedWorker;
444
+ };
445
+ export default sharedWorkerConstructor;
446
+ }
447
+
448
+ declare module '*?sharedworker&inline' {
449
+ const sharedWorkerConstructor: {
450
+ new (): SharedWorker;
451
+ };
452
+ export default sharedWorkerConstructor;
453
+ }
454
+
455
+ declare module '*?sharedworker&url' {
456
+ const src: string;
457
+ export default src;
458
+ }
459
+
460
+ declare module '*?raw' {
461
+ const src: string;
462
+ export default src;
463
+ }
464
+
465
+ declare module '*?url' {
466
+ const src: string;
467
+ export default src;
468
+ }
469
+
470
+ declare module '*?inline' {
29
471
  const src: string;
30
472
  export default src;
31
473
  }
@@ -74,9 +74,9 @@ const html = renderToHtml(tokens, {
74
74
  // Handle code wrapping
75
75
  // if wrap=null, do nothing.
76
76
  if (wrap === false) {
77
- style += '; overflow-x: auto;"';
77
+ style += '; overflow-x: auto;';
78
78
  } else if (wrap === true) {
79
- style += '; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;"';
79
+ style += '; overflow-x: auto; white-space: pre-wrap; word-wrap: break-word;';
80
80
  }
81
81
  return `<${tag} class="${className}" style="${style}" tabindex="0">${children}</${tag}>`;
82
82
  },
@@ -38,12 +38,21 @@ const { fallback = 'animate' } = Astro.props as Props;
38
38
 
39
39
  const throttle = (cb: (...args: any[]) => any, delay: number) => {
40
40
  let wait = false;
41
+ // During the waiting time additional events are lost.
42
+ // So repeat the callback at the end if we have swallowed events.
43
+ let onceMore = false;
41
44
  return (...args: any[]) => {
42
- if (wait) return;
43
-
45
+ if (wait) {
46
+ onceMore = true;
47
+ return;
48
+ }
44
49
  cb(...args);
45
50
  wait = true;
46
51
  setTimeout(() => {
52
+ if (onceMore) {
53
+ onceMore = false;
54
+ cb(...args);
55
+ }
47
56
  wait = false;
48
57
  }, delay);
49
58
  };
@@ -63,9 +72,16 @@ const { fallback = 'animate' } = Astro.props as Props;
63
72
  return 'animate';
64
73
  }
65
74
 
75
+ function markScriptsExec() {
76
+ for (const script of document.scripts) {
77
+ script.dataset.astroExec = '';
78
+ }
79
+ }
80
+
66
81
  function runScripts() {
67
82
  let wait = Promise.resolve();
68
83
  for (const script of Array.from(document.scripts)) {
84
+ if (script.dataset.astroExec === '') continue;
69
85
  const s = document.createElement('script');
70
86
  s.innerHTML = script.innerHTML;
71
87
  for (const attr of script.attributes) {
@@ -77,6 +93,7 @@ const { fallback = 'animate' } = Astro.props as Props;
77
93
  }
78
94
  s.setAttribute(attr.name, attr.value);
79
95
  }
96
+ s.dataset.astroExec = '';
80
97
  script.replaceWith(s);
81
98
  }
82
99
  return wait;
@@ -100,10 +117,27 @@ const { fallback = 'animate' } = Astro.props as Props;
100
117
  const href = el.getAttribute('href');
101
118
  return doc.head.querySelector(`link[rel=stylesheet][href="${href}"]`);
102
119
  }
120
+ if (el.tagName === 'SCRIPT') {
121
+ let s1 = el as HTMLScriptElement;
122
+ for (const s2 of doc.scripts) {
123
+ if (
124
+ // Inline
125
+ (s1.textContent && s1.textContent === s2.textContent) ||
126
+ // External
127
+ (s1.type === s2.type && s1.src === s2.src)
128
+ ) {
129
+ return s2;
130
+ }
131
+ }
132
+ }
103
133
  return null;
104
134
  };
105
135
 
106
136
  const swap = () => {
137
+ // noscript tags inside head element are not honored on swap (#7969).
138
+ // Remove them before swapping.
139
+ doc.querySelectorAll('head noscript').forEach((el) => el.remove());
140
+
107
141
  // Swap head
108
142
  for (const el of Array.from(document.head.children)) {
109
143
  const newEl = persistedHeadElement(el);
@@ -132,8 +166,14 @@ const { fallback = 'animate' } = Astro.props as Props;
132
166
  }
133
167
  }
134
168
 
169
+ if (state?.scrollY === 0 && location.hash) {
170
+ const id = decodeURIComponent(location.hash.slice(1));
171
+ state.scrollY = document.getElementById(id)?.offsetTop || 0;
172
+ }
135
173
  if (state?.scrollY != null) {
136
174
  scrollTo(0, state.scrollY);
175
+ // Overwrite erroneous updates by the scroll handler during transition
176
+ persistState(state);
137
177
  }
138
178
 
139
179
  triggerEvent('astro:beforeload');
@@ -203,6 +243,7 @@ const { fallback = 'animate' } = Astro.props as Props;
203
243
  } finally {
204
244
  document.documentElement.removeAttribute('data-astro-transition');
205
245
  await runScripts();
246
+ markScriptsExec();
206
247
  onload();
207
248
  }
208
249
  }
@@ -221,6 +262,8 @@ const { fallback = 'animate' } = Astro.props as Props;
221
262
  }
222
263
 
223
264
  if (supportsViewTransitions || getFallback() !== 'none') {
265
+ markScriptsExec();
266
+
224
267
  document.addEventListener('click', (ev) => {
225
268
  let link = ev.target;
226
269
  if (link instanceof Element && link.tagName !== 'A') {
@@ -235,7 +278,10 @@ const { fallback = 'animate' } = Astro.props as Props;
235
278
  link.href &&
236
279
  (!link.target || link.target === '_self') &&
237
280
  link.origin === location.origin &&
238
- !link.hash &&
281
+ !(
282
+ // Same page means same path and same query params
283
+ (location.pathname === link.pathname && location.search === link.search)
284
+ ) &&
239
285
  ev.button === 0 && // left clicks only
240
286
  !ev.metaKey && // new tab (mac)
241
287
  !ev.ctrlKey && // new tab (windows)
package/config.d.ts CHANGED
@@ -24,3 +24,10 @@ export function sharpImageService(): ImageServiceConfig;
24
24
  * Return the configuration needed to use the Squoosh-based image service
25
25
  */
26
26
  export function squooshImageService(): ImageServiceConfig;
27
+
28
+ /**
29
+ * Return the configuration needed to use the passthrough image service. This image services does not perform
30
+ * any image transformations, and is mainly useful when your platform does not support other image services, or you are
31
+ * not using Astro's built-in image processing.
32
+ */
33
+ export function passthroughImageService(): ImageServiceConfig;
package/config.mjs CHANGED
@@ -13,3 +13,10 @@ export function squooshImageService() {
13
13
  config: {},
14
14
  };
15
15
  }
16
+
17
+ export function passthroughImageService() {
18
+ return {
19
+ entrypoint: 'astro/assets/services/noop',
20
+ config: {},
21
+ };
22
+ }
@@ -10,7 +10,9 @@ declare module 'astro:content' {
10
10
 
11
11
  declare module 'astro:content' {
12
12
  export { z } from 'astro/zod';
13
- export type CollectionEntry<C extends keyof AnyEntryMap> = AnyEntryMap[C][keyof AnyEntryMap[C]];
13
+
14
+ type Flatten<T> = T extends { [K: string]: infer U } ? U : never;
15
+ export type CollectionEntry<C extends keyof AnyEntryMap> = Flatten<AnyEntryMap[C]>;
14
16
 
15
17
  // TODO: Remove this when having this fallback is no longer relevant. 2.3? 3.0? - erika, 2023-04-04
16
18
  /**