astro 1.0.7 → 1.1.0-next.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 (170) hide show
  1. package/astro-jsx.d.ts +7 -7
  2. package/dist/{types/@types → @types}/astro.d.ts +89 -28
  3. package/dist/{types/cli → cli}/check/index.d.ts +0 -0
  4. package/dist/{types/cli → cli}/check/print.d.ts +0 -0
  5. package/dist/{types/cli → cli}/index.d.ts +0 -0
  6. package/dist/{types/cli → cli}/open.d.ts +0 -0
  7. package/dist/{types/cli → cli}/telemetry.d.ts +0 -0
  8. package/dist/{types/core → core}/add/babel.d.ts +0 -0
  9. package/dist/{types/core → core}/add/imports.d.ts +0 -0
  10. package/dist/{types/core → core}/add/index.d.ts +0 -0
  11. package/dist/core/add/index.js +10 -7
  12. package/dist/{types/core → core}/add/wrapper.d.ts +0 -0
  13. package/dist/{types/core → core}/app/common.d.ts +0 -0
  14. package/dist/{types/core → core}/app/index.d.ts +0 -0
  15. package/dist/{types/core → core}/app/node.d.ts +0 -0
  16. package/dist/{types/core → core}/app/types.d.ts +0 -0
  17. package/dist/{types/core → core}/build/add-rollup-input.d.ts +0 -0
  18. package/dist/{types/core → core}/build/common.d.ts +0 -0
  19. package/dist/{types/core → core}/build/generate.d.ts +0 -0
  20. package/dist/core/build/generate.js +25 -7
  21. package/dist/{types/core → core}/build/graph.d.ts +3 -2
  22. package/dist/core/build/graph.js +10 -6
  23. package/dist/{types/core → core}/build/index.d.ts +0 -0
  24. package/dist/core/build/index.js +5 -4
  25. package/dist/{types/core → core}/build/internal.d.ts +9 -0
  26. package/dist/core/build/internal.js +29 -3
  27. package/dist/{types/core → core}/build/page-data.d.ts +0 -0
  28. package/dist/core/build/page-data.js +2 -2
  29. package/dist/{types/core → core}/build/static-build.d.ts +0 -0
  30. package/dist/core/build/static-build.js +8 -4
  31. package/dist/{types/core → core}/build/types.d.ts +3 -1
  32. package/dist/{types/core → core}/build/util.d.ts +0 -0
  33. package/dist/{types/core → core}/build/vite-plugin-analyzer.d.ts +0 -0
  34. package/dist/core/build/vite-plugin-analyzer.js +2 -2
  35. package/dist/{types/core → core}/build/vite-plugin-css.d.ts +0 -0
  36. package/dist/core/build/vite-plugin-css.js +59 -12
  37. package/dist/{types/core → core}/build/vite-plugin-hoisted-scripts.d.ts +0 -0
  38. package/dist/{types/core → core}/build/vite-plugin-internals.d.ts +0 -0
  39. package/dist/{types/core → core}/build/vite-plugin-pages.d.ts +0 -0
  40. package/dist/{types/core → core}/build/vite-plugin-ssr.d.ts +0 -0
  41. package/dist/core/build/vite-plugin-ssr.js +3 -3
  42. package/dist/{types/core → core}/config.d.ts +11 -1
  43. package/dist/core/config.js +5 -2
  44. package/dist/{types/core → core}/create-vite.d.ts +0 -0
  45. package/dist/core/create-vite.js +1 -1
  46. package/dist/{types/core → core}/dev/index.d.ts +0 -0
  47. package/dist/core/dev/index.js +6 -6
  48. package/dist/{types/core → core}/endpoint/dev/index.d.ts +0 -0
  49. package/dist/{types/core → core}/endpoint/index.d.ts +0 -0
  50. package/dist/{types/core → core}/errors.d.ts +0 -0
  51. package/dist/{types/core → core}/logger/console.d.ts +0 -0
  52. package/dist/{types/core → core}/logger/core.d.ts +0 -0
  53. package/dist/{types/core → core}/logger/node.d.ts +0 -0
  54. package/dist/{types/core → core}/messages.d.ts +0 -0
  55. package/dist/core/messages.js +2 -2
  56. package/dist/{types/core → core}/path.d.ts +0 -0
  57. package/dist/{types/core → core}/polyfill.d.ts +0 -0
  58. package/dist/{types/core → core}/preview/index.d.ts +0 -0
  59. package/dist/{types/core → core}/preview/util.d.ts +0 -0
  60. package/dist/{types/core → core}/render/core.d.ts +0 -0
  61. package/dist/{types/core → core}/render/dev/css.d.ts +0 -0
  62. package/dist/{types/core → core}/render/dev/index.d.ts +0 -0
  63. package/dist/{types/core → core}/render/dev/resolve.d.ts +0 -0
  64. package/dist/{types/core → core}/render/dev/scripts.d.ts +0 -0
  65. package/dist/{types/core → core}/render/dev/vite.d.ts +0 -0
  66. package/dist/{types/core → core}/render/paginate.d.ts +0 -0
  67. package/dist/{types/core → core}/render/result.d.ts +0 -0
  68. package/dist/core/render/result.js +18 -7
  69. package/dist/{types/core → core}/render/route-cache.d.ts +0 -0
  70. package/dist/{types/core → core}/render/script.d.ts +0 -0
  71. package/dist/{types/core → core}/render/ssr-element.d.ts +0 -0
  72. package/dist/{types/core → core}/render/util.d.ts +0 -0
  73. package/dist/{types/core → core}/request.d.ts +0 -0
  74. package/dist/{types/core → core}/routing/index.d.ts +0 -0
  75. package/dist/{types/core → core}/routing/manifest/create.d.ts +0 -0
  76. package/dist/{types/core → core}/routing/manifest/generator.d.ts +0 -0
  77. package/dist/{types/core → core}/routing/manifest/serialization.d.ts +0 -0
  78. package/dist/{types/core → core}/routing/match.d.ts +0 -0
  79. package/dist/{types/core → core}/routing/params.d.ts +0 -0
  80. package/dist/{types/core → core}/routing/validation.d.ts +0 -0
  81. package/dist/{types/core → core}/util.d.ts +0 -0
  82. package/dist/core/util.js +1 -1
  83. package/dist/{types/events → events}/error.d.ts +0 -0
  84. package/dist/{types/events → events}/index.d.ts +0 -0
  85. package/dist/{types/events → events}/session.d.ts +0 -0
  86. package/dist/{types/integrations → integrations}/index.d.ts +19 -9
  87. package/dist/integrations/index.js +99 -35
  88. package/dist/{types/jsx → jsx}/babel.d.ts +0 -0
  89. package/dist/jsx/babel.js +14 -0
  90. package/dist/{types/jsx → jsx}/renderer.d.ts +0 -0
  91. package/dist/{types/jsx → jsx}/server.d.ts +0 -0
  92. package/dist/{types/jsx-runtime → jsx-runtime}/index.d.ts +0 -0
  93. package/dist/{types/runtime → runtime}/client/events.d.ts +0 -0
  94. package/dist/{types/runtime → runtime}/client/hmr.d.ts +0 -0
  95. package/dist/{types/runtime → runtime}/client/idle.d.ts +0 -0
  96. package/dist/{types/runtime → runtime}/client/idle.prebuilt.d.ts +0 -0
  97. package/dist/{types/runtime → runtime}/client/load.d.ts +0 -0
  98. package/dist/{types/runtime → runtime}/client/load.prebuilt.d.ts +0 -0
  99. package/dist/{types/runtime → runtime}/client/media.d.ts +0 -0
  100. package/dist/{types/runtime → runtime}/client/media.prebuilt.d.ts +0 -0
  101. package/dist/{types/runtime → runtime}/client/only.d.ts +0 -0
  102. package/dist/{types/runtime → runtime}/client/only.prebuilt.d.ts +0 -0
  103. package/dist/{types/runtime → runtime}/client/visible.d.ts +0 -0
  104. package/dist/{types/runtime → runtime}/client/visible.prebuilt.d.ts +0 -0
  105. package/dist/{types/runtime → runtime}/server/astro-global.d.ts +0 -0
  106. package/dist/runtime/server/astro-global.js +1 -1
  107. package/dist/{types/runtime → runtime}/server/astro-island.d.ts +0 -0
  108. package/dist/runtime/server/astro-island.js +5 -4
  109. package/dist/runtime/server/astro-island.prebuilt.d.ts +7 -0
  110. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  111. package/dist/{types/runtime → runtime}/server/endpoint.d.ts +0 -0
  112. package/dist/{types/runtime → runtime}/server/escape.d.ts +0 -0
  113. package/dist/{types/runtime → runtime}/server/hydration.d.ts +0 -0
  114. package/dist/{types/runtime → runtime}/server/index.d.ts +0 -0
  115. package/dist/{types/runtime → runtime}/server/jsx.d.ts +0 -0
  116. package/dist/{types/runtime → runtime}/server/metadata.d.ts +0 -0
  117. package/dist/{types/runtime → runtime}/server/render/any.d.ts +0 -0
  118. package/dist/{types/runtime → runtime}/server/render/astro.d.ts +0 -0
  119. package/dist/{types/runtime → runtime}/server/render/common.d.ts +0 -0
  120. package/dist/{types/runtime → runtime}/server/render/component.d.ts +0 -0
  121. package/dist/{types/runtime → runtime}/server/render/dom.d.ts +0 -0
  122. package/dist/{types/runtime → runtime}/server/render/head.d.ts +0 -0
  123. package/dist/{types/runtime → runtime}/server/render/index.d.ts +0 -0
  124. package/dist/{types/runtime → runtime}/server/render/page.d.ts +0 -0
  125. package/dist/{types/runtime → runtime}/server/render/types.d.ts +0 -0
  126. package/dist/{types/runtime → runtime}/server/render/util.d.ts +0 -0
  127. package/dist/{types/runtime → runtime}/server/response.d.ts +0 -0
  128. package/dist/{types/runtime → runtime}/server/scripts.d.ts +0 -0
  129. package/dist/{types/runtime → runtime}/server/serialize.d.ts +0 -0
  130. package/dist/{types/runtime → runtime}/server/shorthash.d.ts +0 -0
  131. package/dist/{types/runtime → runtime}/server/util.d.ts +0 -0
  132. package/dist/{types/template → template}/4xx.d.ts +0 -0
  133. package/dist/{types/template → template}/css.d.ts +0 -0
  134. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/compile.d.ts +5 -3
  135. package/dist/vite-plugin-astro/compile.js +18 -30
  136. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/hmr.d.ts +1 -10
  137. package/dist/vite-plugin-astro/hmr.js +4 -24
  138. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/index.d.ts +0 -0
  139. package/dist/vite-plugin-astro/index.js +14 -14
  140. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/query.d.ts +0 -0
  141. package/dist/vite-plugin-astro/styles.d.ts +18 -0
  142. package/dist/vite-plugin-astro/styles.js +23 -18
  143. package/dist/{types/vite-plugin-astro → vite-plugin-astro}/types.d.ts +0 -0
  144. package/dist/{types/vite-plugin-astro-postprocess → vite-plugin-astro-postprocess}/index.d.ts +0 -0
  145. package/dist/{types/vite-plugin-astro-server → vite-plugin-astro-server}/index.d.ts +0 -0
  146. package/dist/{types/vite-plugin-config-alias → vite-plugin-config-alias}/index.d.ts +0 -0
  147. package/dist/{types/vite-plugin-env → vite-plugin-env}/index.d.ts +0 -0
  148. package/dist/{types/vite-plugin-html → vite-plugin-html}/index.d.ts +0 -0
  149. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/escape.d.ts +0 -0
  150. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/index.d.ts +0 -0
  151. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/slots.d.ts +0 -0
  152. package/dist/{types/vite-plugin-html → vite-plugin-html}/transform/utils.d.ts +0 -0
  153. package/dist/{types/vite-plugin-integrations-container → vite-plugin-integrations-container}/index.d.ts +3 -1
  154. package/dist/vite-plugin-integrations-container/index.js +3 -2
  155. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/index.d.ts +0 -0
  156. package/dist/{types/vite-plugin-jsx → vite-plugin-jsx}/tag.d.ts +0 -0
  157. package/dist/{types/vite-plugin-markdown → vite-plugin-markdown}/index.d.ts +0 -0
  158. package/dist/vite-plugin-markdown/index.js +2 -0
  159. package/dist/{types/vite-plugin-markdown-legacy → vite-plugin-markdown-legacy}/index.d.ts +0 -0
  160. package/dist/vite-plugin-markdown-legacy/index.js +8 -4
  161. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/index.d.ts +0 -0
  162. package/dist/{types/vite-plugin-scripts → vite-plugin-scripts}/page-ssr.d.ts +0 -0
  163. package/dist/{types/vite-plugin-utils → vite-plugin-utils}/index.d.ts +0 -0
  164. package/env.d.ts +3 -3
  165. package/package.json +14 -8
  166. package/tsconfigs/base.json +20 -0
  167. package/tsconfigs/strict.json +9 -0
  168. package/tsconfigs/strictest.json +24 -0
  169. package/dist/types/runtime/server/astro-island.prebuilt.d.ts +0 -7
  170. package/dist/types/vite-plugin-astro/styles.d.ts +0 -16
package/astro-jsx.d.ts CHANGED
@@ -23,12 +23,12 @@ declare namespace astroHTML.JSX {
23
23
  children?: Children;
24
24
  }
25
25
 
26
- type AstroBuiltinProps = import('./dist/types/@types/astro').AstroBuiltinProps;
27
- type AstroBuiltinAttributes = import('./dist/types/@types/astro').AstroBuiltinAttributes;
28
- type AstroDefineVarsAttribute = import('./dist/types/@types/astro').AstroDefineVarsAttribute;
29
- type AstroScriptAttributes = import('./dist/types/@types/astro').AstroScriptAttributes &
26
+ type AstroBuiltinProps = import('./dist/@types/astro').AstroBuiltinProps;
27
+ type AstroBuiltinAttributes = import('./dist/@types/astro').AstroBuiltinAttributes;
28
+ type AstroDefineVarsAttribute = import('./dist/@types/astro').AstroDefineVarsAttribute;
29
+ type AstroScriptAttributes = import('./dist/@types/astro').AstroScriptAttributes &
30
30
  AstroDefineVarsAttribute;
31
- type AstroStyleAttributes = import('./dist/types/@types/astro').AstroStyleAttributes &
31
+ type AstroStyleAttributes = import('./dist/@types/astro').AstroStyleAttributes &
32
32
  AstroDefineVarsAttribute;
33
33
 
34
34
  // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
@@ -548,7 +548,7 @@ declare namespace astroHTML.JSX {
548
548
  | 'strict-origin-when-cross-origin'
549
549
  | 'unsafe-url';
550
550
 
551
- type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top';
551
+ type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top' | (string & {});
552
552
 
553
553
  interface AnchorHTMLAttributes extends HTMLAttributes {
554
554
  download?: string | boolean | undefined | null;
@@ -756,7 +756,7 @@ declare namespace astroHTML.JSX {
756
756
  size?: number | string | undefined | null;
757
757
  src?: string | undefined | null;
758
758
  step?: number | string | undefined | null;
759
- type?: HTMLInputTypeAttribute | string | undefined | null;
759
+ type?: HTMLInputTypeAttribute | undefined | null;
760
760
  value?: string | string[] | number | undefined | null;
761
761
  width?: number | string | undefined | null;
762
762
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig } from '@astrojs/markdown-remark';
2
+ import type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, RemarkRehype, ShikiConfig } from '@astrojs/markdown-remark';
3
3
  import type * as babel from '@babel/core';
4
4
  import type { AddressInfo } from 'net';
5
5
  import type * as vite from 'vite';
@@ -179,7 +179,7 @@ export interface AstroGlobal extends AstroGlobalPartial {
179
179
  */
180
180
  has(slotName: string): boolean;
181
181
  /**
182
- * Asychronously renders this slot and returns HTML
182
+ * Asynchronously renders this slot and returns a string
183
183
  *
184
184
  * Example usage:
185
185
  * ```astro
@@ -192,6 +192,21 @@ export interface AstroGlobal extends AstroGlobalPartial {
192
192
  * <Fragment set:html={html} />
193
193
  * ```
194
194
  *
195
+ * A second parameters can be used to pass arguments to a slotted callback
196
+ *
197
+ * Example usage:
198
+ * ```astro
199
+ * ---
200
+ * html = await Astro.slots.render('default', ["Hello", "World"])
201
+ * ---
202
+ * ```
203
+ * Each item in the array will be passed as an argument that you can use like so:
204
+ * ```astro
205
+ * <Component>
206
+ * {(hello, world) => <div>{hello}, {world}!</div>}
207
+ * </Component>
208
+ * ```
209
+ *
195
210
  * [Astro reference](https://docs.astro.build/en/reference/api-reference/#astroslots)
196
211
  */
197
212
  render(slotName: string, args?: any[]): Promise<string>;
@@ -377,7 +392,7 @@ export interface AstroUserConfig {
377
392
  * @name trailingSlash
378
393
  * @type {('always' | 'never' | 'ignore')}
379
394
  * @default `'ignore'`
380
- * @see buildOptions.pageUrlFormat
395
+ * @see build.format
381
396
  * @description
382
397
  *
383
398
  * Set the route matching behavior of the dev server. Choose from the following options:
@@ -463,6 +478,13 @@ export interface AstroUserConfig {
463
478
  * }
464
479
  * }
465
480
  * ```
481
+ *
482
+ * #### Effect on Astro.url
483
+ * Setting `build.format` controls what `Astro.url` is set to during the build. When it is:
484
+ * - `directory` - The `Astro.url.pathname` will include a trailing slash to mimic folder behavior; ie `/foo/`.
485
+ * - `file` - The `Astro.url.pathname` will include `.html`; ie `/foo.html`.
486
+ *
487
+ * This means that when you create relative URLs using `new URL('./relative', Astro.url)`, you will get consistent behavior between dev and build.
466
488
  */
467
489
  format?: 'file' | 'directory';
468
490
  };
@@ -580,17 +602,19 @@ export interface AstroUserConfig {
580
602
  * @name markdown.remarkPlugins
581
603
  * @type {RemarkPlugins}
582
604
  * @description
583
- * Pass a custom [Remark](https://github.com/remarkjs/remark) plugin to customize how your Markdown is built.
605
+ * Pass [remark plugins](https://github.com/remarkjs/remark) to customize how your Markdown is built. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
584
606
  *
585
- * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support and [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
607
+ * :::caution
608
+ * Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
609
+ * :::
586
610
  *
587
611
  * ```js
612
+ * import remarkToc from 'remark-toc';
588
613
  * {
589
614
  * markdown: {
590
- * // Example: The default set of remark plugins used by Astro
591
- * remarkPlugins: ['remark-gfm', 'remark-smartypants'],
592
- * },
593
- * };
615
+ * remarkPlugins: [remarkToc]
616
+ * }
617
+ * }
594
618
  * ```
595
619
  */
596
620
  remarkPlugins?: RemarkPlugins;
@@ -599,20 +623,58 @@ export interface AstroUserConfig {
599
623
  * @name markdown.rehypePlugins
600
624
  * @type {RehypePlugins}
601
625
  * @description
602
- * Pass a custom [Rehype](https://github.com/remarkjs/remark-rehype) plugin to customize how your Markdown is built.
626
+ * Pass [rehype plugins](https://github.com/remarkjs/remark-rehype) to customize how your Markdown's output HTML is processed. You can import and apply the plugin function (recommended), or pass the plugin name as a string.
627
+ *
628
+ * :::caution
629
+ * Providing a list of plugins will **remove** our default plugins. To preserve these defaults, see the `extendDefaultPlugins` flag.
630
+ * :::
631
+ *
632
+ * ```js
633
+ * import rehypeMinifyHtml from 'rehype-minify';
634
+ * {
635
+ * markdown: {
636
+ * rehypePlugins: [rehypeMinifyHtml]
637
+ * }
638
+ * }
639
+ * ```
640
+ */
641
+ rehypePlugins?: RehypePlugins;
642
+ /**
643
+ * @docs
644
+ * @name markdown.extendDefaultPlugins
645
+ * @type {boolean}
646
+ * @default `false`
647
+ * @description
648
+ * Astro applies the [GitHub-flavored Markdown](https://github.com/remarkjs/remark-gfm) and [Smartypants](https://github.com/silvenon/remark-smartypants) plugins by default. When adding your own remark or rehype plugins, you can preserve these defaults by setting the `extendDefaultPlugins` flag to `true`:
603
649
  *
604
- * **Note:** Enabling custom `remarkPlugins` or `rehypePlugins` removes Astro's built-in support for [GitHub-flavored Markdown](https://github.github.com/gfm/) support and [Smartypants](https://github.com/silvenon/remark-smartypants). You must explicitly add these plugins to your `astro.config.mjs` file, if desired.
650
+ * ```js
651
+ * {
652
+ * markdown: {
653
+ * extendDefaultPlugins: true,
654
+ * remarkPlugins: [exampleRemarkPlugin],
655
+ * rehypePlugins: [exampleRehypePlugin],
656
+ * }
657
+ * }
658
+ * ```
659
+ */
660
+ extendDefaultPlugins?: boolean;
661
+ /**
662
+ * @docs
663
+ * @name markdown.remarkRehype
664
+ * @type {RemarkRehype}
665
+ * @description
666
+ * Pass options to [remark-rehype](https://github.com/remarkjs/remark-rehype#api).
605
667
  *
606
668
  * ```js
607
669
  * {
608
670
  * markdown: {
609
- * // Example: The default set of rehype plugins used by Astro
610
- * rehypePlugins: [],
671
+ * // Example: Translate the footnotes text to another language, here are the default English values
672
+ * remarkRehype: { footnoteLabel: "Footnotes", footnoteBackLabel: "Back to content"},
611
673
  * },
612
674
  * };
613
675
  * ```
614
676
  */
615
- rehypePlugins?: RehypePlugins;
677
+ remarkRehype?: RemarkRehype;
616
678
  };
617
679
  /**
618
680
  * @docs
@@ -633,7 +695,7 @@ export interface AstroUserConfig {
633
695
  * }
634
696
  * ```
635
697
  */
636
- integrations?: Array<AstroIntegration | AstroIntegration[]>;
698
+ integrations?: Array<AstroIntegration | (AstroIntegration | false | undefined | null)[] | false | undefined | null>;
637
699
  /**
638
700
  * @docs
639
701
  * @kind heading
@@ -765,36 +827,35 @@ export interface AstroInstance {
765
827
  }
766
828
  export interface MarkdownInstance<T extends Record<string, any>> {
767
829
  frontmatter: T;
830
+ /** Absolute file path (e.g. `/home/user/projects/.../file.md`) */
768
831
  file: string;
832
+ /** Browser URL for files under `/src/pages` (e.g. `/en/guides/markdown-content`) */
769
833
  url: string | undefined;
834
+ /** Component to render content in `.astro` files. Usage: `<Content />` */
770
835
  Content: AstroComponentFactory;
771
- /** raw Markdown file content, excluding frontmatter */
836
+ /** raw Markdown file content, excluding layout HTML and YAML frontmatter */
772
837
  rawContent(): string;
773
- /** Markdown file compiled to valid Astro syntax. Queryable with most HTML parsing libraries */
774
- compiledContent(): Promise<string>;
775
- getHeadings(): Promise<MarkdownHeading[]>;
838
+ /** Markdown file compiled to HTML, excluding layout HTML */
839
+ compiledContent(): string;
840
+ /** List of headings (h1 -> h6) with associated metadata */
841
+ getHeadings(): MarkdownHeading[];
776
842
  /** @deprecated Renamed to `getHeadings()` */
777
843
  getHeaders(): void;
778
- default: () => Promise<{
779
- metadata: MarkdownMetadata;
780
- frontmatter: MarkdownContent<T>;
781
- $$metadata: Metadata;
782
- default: AstroComponentFactory;
783
- }>;
844
+ default: AstroComponentFactory;
784
845
  }
785
- export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent' | 'Content' | 'default'> {
846
+ export interface MDXInstance<T> extends Omit<MarkdownInstance<T>, 'rawContent' | 'compiledContent'> {
786
847
  /** MDX does not support rawContent! If you need to read the Markdown contents to calculate values (ex. reading time), we suggest injecting frontmatter via remark plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
787
848
  rawContent: never;
788
849
  /** MDX does not support compiledContent! If you need to read the HTML contents to calculate values (ex. reading time), we suggest injecting frontmatter via rehype plugins. Learn more on our docs: https://docs.astro.build/en/guides/integrations-guide/mdx/#inject-frontmatter-via-remark-or-rehype-plugins */
789
850
  compiledContent: never;
790
- default: AstroComponentFactory;
791
- Content: AstroComponentFactory;
792
851
  }
793
852
  export interface MarkdownLayoutProps<T extends Record<string, any>> {
794
853
  frontmatter: {
795
854
  file: MarkdownInstance<T>['file'];
796
855
  url: MarkdownInstance<T>['url'];
797
856
  } & T;
857
+ file: MarkdownInstance<T>['file'];
858
+ url: MarkdownInstance<T>['url'];
798
859
  headings: MarkdownHeading[];
799
860
  rawContent: MarkdownInstance<T>['rawContent'];
800
861
  compiledContent: MarkdownInstance<T>['compiledContent'];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -517,7 +517,7 @@ ${message}`
517
517
  }
518
518
  }
519
519
  async function fetchPackageJson(scope, name, tag) {
520
- const packageName = `${scope ? `@${scope}/` : ""}${name}`;
520
+ const packageName = `${scope ? `${scope}/` : ""}${name}`;
521
521
  const res = await fetch(`https://registry.npmjs.org/${packageName}/${tag}`);
522
522
  if (res.status === 404) {
523
523
  return new Error();
@@ -535,10 +535,12 @@ async function validateIntegrations(integrations) {
535
535
  throw new Error(`${bold(integration)} does not appear to be a valid package name!`);
536
536
  }
537
537
  let { scope, name, tag } = parsed;
538
- let pkgJson = null;
539
- let pkgType = "first-party";
540
- if (!scope) {
541
- const firstPartyPkgCheck = await fetchPackageJson("astrojs", name, tag);
538
+ let pkgJson;
539
+ let pkgType;
540
+ if (scope && scope !== "@astrojs") {
541
+ pkgType = "third-party";
542
+ } else {
543
+ const firstPartyPkgCheck = await fetchPackageJson("@astrojs", name, tag);
542
544
  if (firstPartyPkgCheck instanceof Error) {
543
545
  spinner.warn(
544
546
  yellow(`${bold(integration)} is not an official Astro package. Use at your own risk!`)
@@ -559,6 +561,7 @@ async function validateIntegrations(integrations) {
559
561
  spinner.start("Resolving with third party packages...");
560
562
  pkgType = "third-party";
561
563
  } else {
564
+ pkgType = "first-party";
562
565
  pkgJson = firstPartyPkgCheck;
563
566
  }
564
567
  }
@@ -570,8 +573,8 @@ async function validateIntegrations(integrations) {
570
573
  pkgJson = thirdPartyPkgCheck;
571
574
  }
572
575
  }
573
- const resolvedScope = pkgType === "first-party" ? "astrojs" : scope;
574
- const packageName = `${resolvedScope ? `@${resolvedScope}/` : ""}${name}`;
576
+ const resolvedScope = pkgType === "first-party" ? "@astrojs" : scope;
577
+ const packageName = `${resolvedScope ? `${resolvedScope}/` : ""}${name}`;
575
578
  let dependencies = [
576
579
  [pkgJson["name"], `^${pkgJson["version"]}`]
577
580
  ];
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -19,7 +19,7 @@ import { createRequest } from "../request.js";
19
19
  import { matchRoute } from "../routing/match.js";
20
20
  import { getOutputFilename } from "../util.js";
21
21
  import { getOutFile, getOutFolder } from "./common.js";
22
- import { eachPageData, getPageDataByComponent } from "./internal.js";
22
+ import { eachPageData, getPageDataByComponent, sortedCSS } from "./internal.js";
23
23
  import { getTimeStat } from "./util.js";
24
24
  const MAX_CONCURRENT_RENDERS = 1;
25
25
  function* throttle(max, inPaths) {
@@ -79,7 +79,7 @@ async function generatePage(opts, internals, pageData, ssrEntry, builtPaths) {
79
79
  let timeStart = performance.now();
80
80
  const renderers = ssrEntry.renderers;
81
81
  const pageInfo = getPageDataByComponent(internals, pageData.route.component);
82
- const linkIds = Array.from((pageInfo == null ? void 0 : pageInfo.css) ?? []);
82
+ const linkIds = sortedCSS(pageData);
83
83
  const scripts = (pageInfo == null ? void 0 : pageInfo.hoistedScript) ?? null;
84
84
  const pageModule = ssrEntry.pageMap.get(pageData.component);
85
85
  if (!pageModule) {
@@ -141,9 +141,6 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
141
141
  });
142
142
  opts.routeCache.set(route, result);
143
143
  paths = result.staticPaths.map((staticPath) => staticPath.params && route.generate(staticPath.params)).filter((staticPath) => {
144
- if (!staticPath) {
145
- return false;
146
- }
147
144
  if (!builtPaths.has(removeTrailingForwardSlash(staticPath))) {
148
145
  return true;
149
146
  }
@@ -159,6 +156,21 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
159
156
  function addPageName(pathname, opts) {
160
157
  opts.pageNames.push(pathname.replace(/^\//, ""));
161
158
  }
159
+ function getUrlForPath(pathname, base, origin, format, routeType) {
160
+ const ending = format === "directory" ? "/" : ".html";
161
+ let buildPathname;
162
+ if (pathname === "/" || pathname === "") {
163
+ buildPathname = base;
164
+ } else if (routeType === "endpoint") {
165
+ const buildPathRelative = removeLeadingForwardSlash(pathname);
166
+ buildPathname = base + buildPathRelative;
167
+ } else {
168
+ const buildPathRelative = removeTrailingForwardSlash(removeLeadingForwardSlash(pathname)) + ending;
169
+ buildPathname = base + buildPathRelative;
170
+ }
171
+ const url = new URL(buildPathname, origin);
172
+ return url;
173
+ }
162
174
  async function generatePath(pathname, opts, gopts) {
163
175
  var _a;
164
176
  const { astroConfig, logging, origin, routeCache } = opts;
@@ -168,7 +180,7 @@ async function generatePath(pathname, opts, gopts) {
168
180
  }
169
181
  debug("build", `Generating: ${pathname}`);
170
182
  const site = astroConfig.base !== "/" ? joinPaths(((_a = astroConfig.site) == null ? void 0 : _a.toString()) || "http://localhost/", astroConfig.base) : astroConfig.site;
171
- const links = createLinkStylesheetElementSet(linkIds.reverse(), site);
183
+ const links = createLinkStylesheetElementSet(linkIds, site);
172
184
  const scripts = createModuleScriptsSet(hoistedScripts ? [hoistedScripts] : [], site);
173
185
  if (astroConfig._ctx.scripts.some((script) => script.stage === "page")) {
174
186
  const hashedFilePath = internals.entrySpecifierToBundleMap.get(PAGE_SCRIPT_ID);
@@ -190,7 +202,13 @@ async function generatePath(pathname, opts, gopts) {
190
202
  }
191
203
  }
192
204
  const ssr = opts.astroConfig.output === "server";
193
- const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
205
+ const url = getUrlForPath(
206
+ pathname,
207
+ opts.astroConfig.base,
208
+ origin,
209
+ opts.astroConfig.build.format,
210
+ pageData.route.type
211
+ );
194
212
  const options = {
195
213
  adapterName: void 0,
196
214
  links,
@@ -1,7 +1,8 @@
1
1
  import type { GetModuleInfo, ModuleInfo } from 'rollup';
2
2
  export declare function walkParentInfos(id: string, ctx: {
3
3
  getModuleInfo: GetModuleInfo;
4
- }, seen?: Set<string>): Generator<ModuleInfo, void, unknown>;
4
+ }, depth?: number, seen?: Set<string>): Generator<[ModuleInfo, number], void, unknown>;
5
+ export declare function moduleIsTopLevelPage(info: ModuleInfo): boolean;
5
6
  export declare function getTopLevelPages(id: string, ctx: {
6
7
  getModuleInfo: GetModuleInfo;
7
- }): Generator<ModuleInfo, void, unknown>;
8
+ }): Generator<[ModuleInfo, number], void, unknown>;
@@ -1,26 +1,30 @@
1
1
  import { resolvedPagesVirtualModuleId } from "../app/index.js";
2
- function* walkParentInfos(id, ctx, seen = /* @__PURE__ */ new Set()) {
2
+ function* walkParentInfos(id, ctx, depth = 0, seen = /* @__PURE__ */ new Set()) {
3
3
  seen.add(id);
4
4
  const info = ctx.getModuleInfo(id);
5
5
  if (info) {
6
- yield info;
6
+ yield [info, depth];
7
7
  }
8
8
  const importers = ((info == null ? void 0 : info.importers) || []).concat((info == null ? void 0 : info.dynamicImporters) || []);
9
9
  for (const imp of importers) {
10
10
  if (seen.has(imp)) {
11
11
  continue;
12
12
  }
13
- yield* walkParentInfos(imp, ctx, seen);
13
+ yield* walkParentInfos(imp, ctx, ++depth, seen);
14
14
  }
15
15
  }
16
+ function moduleIsTopLevelPage(info) {
17
+ return info.importers[0] === resolvedPagesVirtualModuleId;
18
+ }
16
19
  function* getTopLevelPages(id, ctx) {
17
- for (const info of walkParentInfos(id, ctx)) {
18
- if ((info == null ? void 0 : info.importers[0]) === resolvedPagesVirtualModuleId) {
19
- yield info;
20
+ for (const res of walkParentInfos(id, ctx)) {
21
+ if (moduleIsTopLevelPage(res[0])) {
22
+ yield res;
20
23
  }
21
24
  }
22
25
  }
23
26
  export {
24
27
  getTopLevelPages,
28
+ moduleIsTopLevelPage,
25
29
  walkParentInfos
26
30
  };
File without changes
@@ -38,7 +38,7 @@ class AstroBuilder {
38
38
  debug("build", "Initial setup...");
39
39
  const { logging } = this;
40
40
  this.timer.init = performance.now();
41
- this.config = await runHookConfigSetup({ config: this.config, command: "build" });
41
+ this.config = await runHookConfigSetup({ config: this.config, command: "build", logging });
42
42
  this.manifest = createRouteManifest({ config: this.config }, this.logging);
43
43
  const viteConfig = await createVite(
44
44
  {
@@ -51,7 +51,7 @@ class AstroBuilder {
51
51
  },
52
52
  { astroConfig: this.config, logging, mode: "build" }
53
53
  );
54
- await runHookConfigDone({ config: this.config });
54
+ await runHookConfigDone({ config: this.config, logging });
55
55
  return { viteConfig };
56
56
  }
57
57
  async build({ viteConfig }) {
@@ -60,7 +60,7 @@ class AstroBuilder {
60
60
  server: new URL("./server/", this.config.outDir),
61
61
  serverEntry: "entry.mjs"
62
62
  };
63
- await runHookBuildStart({ config: this.config, buildConfig });
63
+ await runHookBuildStart({ config: this.config, buildConfig, logging: this.logging });
64
64
  info(this.logging, "build", `output target: ${colors.green(this.config.output)}`);
65
65
  if (this.config._ctx.adapter) {
66
66
  info(this.logging, "build", `deploy adapter: ${colors.green(this.config._ctx.adapter.name)}`);
@@ -106,7 +106,8 @@ class AstroBuilder {
106
106
  config: this.config,
107
107
  buildConfig,
108
108
  pages: pageNames,
109
- routes: Object.values(allPages).map((pd) => pd.route)
109
+ routes: Object.values(allPages).map((pd) => pd.route),
110
+ logging: this.logging
110
111
  });
111
112
  if (this.logging.level && levels[this.logging.level] <= levels["info"]) {
112
113
  await this.printStats({
@@ -51,3 +51,12 @@ export declare function getPageDataByComponent(internals: BuildInternals, compon
51
51
  export declare function getPageDataByViteID(internals: BuildInternals, viteid: ViteID): PageBuildData | undefined;
52
52
  export declare function hasPageDataByViteID(internals: BuildInternals, viteid: ViteID): boolean;
53
53
  export declare function eachPageData(internals: BuildInternals): Generator<PageBuildData, void, undefined>;
54
+ /**
55
+ * Sort a page's CSS by depth. A higher depth means that the CSS comes from shared subcomponents.
56
+ * A lower depth means it comes directly from the top-level page.
57
+ * The return of this function is an array of CSS paths, with shared CSS on top
58
+ * and page-level CSS on bottom.
59
+ */
60
+ export declare function sortedCSS(pageData: PageBuildData): string[];
61
+ export declare function isHoistedScript(internals: BuildInternals, id: string): boolean;
62
+ export declare function getPageDatasByHoistedScriptId(internals: BuildInternals, id: string): Generator<PageBuildData, void, unknown>;
@@ -2,9 +2,6 @@ import { prependForwardSlash } from "../path.js";
2
2
  import { viteID } from "../util.js";
3
3
  function createBuildInternals() {
4
4
  const pureCSSChunks = /* @__PURE__ */ new Set();
5
- const chunkToReferenceIdMap = /* @__PURE__ */ new Map();
6
- const astroStyleMap = /* @__PURE__ */ new Map();
7
- const astroPageStyleMap = /* @__PURE__ */ new Map();
8
5
  const hoistedScriptIdToHoistedMap = /* @__PURE__ */ new Map();
9
6
  const hoistedScriptIdToPagesMap = /* @__PURE__ */ new Map();
10
7
  return {
@@ -76,6 +73,32 @@ function hasPageDataByViteID(internals, viteid) {
76
73
  function* eachPageData(internals) {
77
74
  yield* internals.pagesByComponent.values();
78
75
  }
76
+ function sortedCSS(pageData) {
77
+ return Array.from(pageData.css).sort((a, b) => {
78
+ let depthA = a[1].depth, depthB = b[1].depth;
79
+ if (depthA === -1) {
80
+ return -1;
81
+ } else if (depthB === -1) {
82
+ return 1;
83
+ } else {
84
+ return depthA > depthB ? -1 : 1;
85
+ }
86
+ }).map(([id]) => id);
87
+ }
88
+ function isHoistedScript(internals, id) {
89
+ return internals.hoistedScriptIdToPagesMap.has(id);
90
+ }
91
+ function* getPageDatasByHoistedScriptId(internals, id) {
92
+ const set = internals.hoistedScriptIdToPagesMap.get(id);
93
+ if (set) {
94
+ for (const pageId of set) {
95
+ const pageData = getPageDataByComponent(internals, pageId.slice(1));
96
+ if (pageData) {
97
+ yield pageData;
98
+ }
99
+ }
100
+ }
101
+ }
79
102
  export {
80
103
  createBuildInternals,
81
104
  eachPageData,
@@ -83,7 +106,10 @@ export {
83
106
  getPageDataByViteID,
84
107
  getPageDatasByChunk,
85
108
  getPageDatasByClientOnlyID,
109
+ getPageDatasByHoistedScriptId,
86
110
  hasPageDataByViteID,
111
+ isHoistedScript,
112
+ sortedCSS,
87
113
  trackClientOnlyPageDatas,
88
114
  trackPageData
89
115
  };
File without changes
@@ -27,7 +27,7 @@ async function collectPagesData(opts) {
27
27
  component: route.component,
28
28
  route,
29
29
  moduleSpecifier: "",
30
- css: /* @__PURE__ */ new Set(),
30
+ css: /* @__PURE__ */ new Map(),
31
31
  hoistedScript: void 0
32
32
  };
33
33
  clearInterval(routeCollectionLogTimeout);
@@ -46,7 +46,7 @@ async function collectPagesData(opts) {
46
46
  component: route.component,
47
47
  route,
48
48
  moduleSpecifier: "",
49
- css: /* @__PURE__ */ new Set(),
49
+ css: /* @__PURE__ */ new Map(),
50
50
  hoistedScript: void 0
51
51
  };
52
52
  }
@@ -122,13 +122,15 @@ async function ssrBuild(opts, internals, input) {
122
122
  vitePluginAnalyzer(internals)
123
123
  ],
124
124
  publicDir: ssr ? false : viteConfig.publicDir,
125
- envPrefix: "PUBLIC_"
125
+ envPrefix: "PUBLIC_",
126
+ base: astroConfig.base
126
127
  };
127
128
  await runHookBuildSetup({
128
129
  config: astroConfig,
129
130
  pages: internals.pagesByComponent,
130
131
  vite: viteBuildConfig,
131
- target: "server"
132
+ target: "server",
133
+ logging: opts.logging
132
134
  });
133
135
  return await vite.build(viteBuildConfig);
134
136
  }
@@ -180,13 +182,15 @@ ${bgGreen(black(" building client "))}`);
180
182
  }),
181
183
  ...viteConfig.plugins || []
182
184
  ],
183
- envPrefix: "PUBLIC_"
185
+ envPrefix: "PUBLIC_",
186
+ base: astroConfig.base
184
187
  };
185
188
  await runHookBuildSetup({
186
189
  config: astroConfig,
187
190
  pages: internals.pagesByComponent,
188
191
  vite: viteBuildConfig,
189
- target: "client"
192
+ target: "client",
193
+ logging: opts.logging
190
194
  });
191
195
  const buildResult = await vite.build(viteBuildConfig);
192
196
  info(opts.logging, null, dim(`Completed in ${getTimeStat(timer, performance.now())}.
@@ -8,7 +8,9 @@ export interface PageBuildData {
8
8
  component: ComponentPath;
9
9
  route: RouteData;
10
10
  moduleSpecifier: string;
11
- css: Set<string>;
11
+ css: Map<string, {
12
+ depth: number;
13
+ }>;
12
14
  hoistedScript: {
13
15
  type: 'inline' | 'external';
14
16
  value: string;
File without changes
@@ -15,7 +15,7 @@ function vitePluginAnalyzer(internals) {
15
15
  hoistedScripts.add(hid);
16
16
  }
17
17
  if (hoistedScripts.size) {
18
- for (const pageInfo of getTopLevelPages(from, this)) {
18
+ for (const [pageInfo] of getTopLevelPages(from, this)) {
19
19
  const pageId = pageInfo.id;
20
20
  for (const hid of hoistedScripts) {
21
21
  if (pageScripts.has(pageId)) {
@@ -77,7 +77,7 @@ function vitePluginAnalyzer(internals) {
77
77
  internals.discoveredClientOnlyComponents.add(cid);
78
78
  clientOnlys.push(cid);
79
79
  }
80
- for (const pageInfo of getTopLevelPages(id, this)) {
80
+ for (const [pageInfo] of getTopLevelPages(id, this)) {
81
81
  const pageData = getPageDataByViteID(internals, pageInfo.id);
82
82
  if (!pageData)
83
83
  continue;