astro 1.0.0-beta.4 → 1.0.0-beta.40

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 (114) hide show
  1. package/LICENSE +61 -0
  2. package/README.md +28 -88
  3. package/astro-jsx.d.ts +4 -1
  4. package/components/Code.astro +1 -1
  5. package/components/Markdown.astro +7 -0
  6. package/components/Shiki.js +24 -0
  7. package/dist/cli/index.js +38 -14
  8. package/dist/cli/telemetry.js +36 -0
  9. package/dist/core/add/consts.js +1 -1
  10. package/dist/core/add/index.js +3 -2
  11. package/dist/core/app/common.js +2 -0
  12. package/dist/core/app/index.js +23 -13
  13. package/dist/core/build/generate.js +10 -11
  14. package/dist/core/build/index.js +1 -4
  15. package/dist/core/build/internal.js +31 -4
  16. package/dist/core/build/page-data.js +13 -25
  17. package/dist/core/build/static-build.js +58 -19
  18. package/dist/{@types/shorthash.d.js → core/build/types.js} +0 -0
  19. package/dist/core/build/vite-plugin-hoisted-scripts.js +13 -7
  20. package/dist/core/build/vite-plugin-pages.js +6 -9
  21. package/dist/core/build/vite-plugin-ssr.js +37 -16
  22. package/dist/core/config.js +73 -19
  23. package/dist/core/create-vite.js +20 -6
  24. package/dist/core/dev/index.js +10 -4
  25. package/dist/core/errors.js +18 -0
  26. package/dist/core/logger/core.js +2 -13
  27. package/dist/core/messages.js +48 -7
  28. package/dist/core/path.js +14 -10
  29. package/dist/core/render/core.js +5 -5
  30. package/dist/core/render/dev/css.js +11 -4
  31. package/dist/core/render/dev/index.js +33 -63
  32. package/dist/core/render/result.js +36 -33
  33. package/dist/core/render/route-cache.js +3 -9
  34. package/dist/core/render/util.js +39 -2
  35. package/dist/core/request.js +31 -1
  36. package/dist/core/routing/manifest/create.js +2 -13
  37. package/dist/core/routing/manifest/generator.js +15 -0
  38. package/dist/core/routing/manifest/serialization.js +35 -18
  39. package/dist/core/routing/params.js +12 -1
  40. package/dist/core/routing/validation.js +7 -0
  41. package/dist/core/util.js +2 -2
  42. package/dist/integrations/index.js +20 -1
  43. package/dist/runtime/client/events.js +25 -0
  44. package/dist/runtime/client/hmr.js +23 -3
  45. package/dist/runtime/client/idle.js +37 -23
  46. package/dist/runtime/client/load.js +30 -16
  47. package/dist/runtime/client/media.js +40 -26
  48. package/dist/runtime/client/only.js +32 -18
  49. package/dist/runtime/client/visible.js +49 -31
  50. package/dist/runtime/server/hydration.js +2 -3
  51. package/dist/runtime/server/index.js +91 -43
  52. package/dist/runtime/server/metadata.js +1 -1
  53. package/dist/runtime/server/shorthash.js +62 -0
  54. package/dist/template/5xx.js +2 -2
  55. package/dist/types/@types/astro.d.ts +213 -112
  56. package/dist/types/cli/telemetry.d.ts +7 -0
  57. package/dist/types/core/add/consts.d.ts +1 -1
  58. package/dist/types/core/add/index.d.ts +3 -1
  59. package/dist/types/core/app/index.d.ts +2 -0
  60. package/dist/types/core/app/types.d.ts +11 -6
  61. package/dist/types/core/build/index.d.ts +3 -1
  62. package/dist/types/core/build/internal.d.ts +8 -13
  63. package/dist/types/core/build/types.d.ts +34 -0
  64. package/dist/types/core/build/vite-plugin-pages.d.ts +0 -2
  65. package/dist/types/core/config.d.ts +73 -32
  66. package/dist/types/core/dev/index.d.ts +5 -1
  67. package/dist/types/core/errors.d.ts +1 -0
  68. package/dist/types/core/messages.d.ts +5 -3
  69. package/dist/types/core/path.d.ts +4 -3
  70. package/dist/types/core/preview/index.d.ts +2 -0
  71. package/dist/types/core/render/core.d.ts +4 -3
  72. package/dist/types/core/render/dev/css.d.ts +1 -1
  73. package/dist/types/core/render/dev/index.d.ts +5 -4
  74. package/dist/types/core/render/result.d.ts +4 -3
  75. package/dist/types/core/render/route-cache.d.ts +1 -2
  76. package/dist/types/core/render/util.d.ts +4 -1
  77. package/dist/types/core/request.d.ts +2 -1
  78. package/dist/types/core/routing/manifest/generator.d.ts +2 -0
  79. package/dist/types/core/routing/manifest/serialization.d.ts +2 -2
  80. package/dist/types/core/routing/params.d.ts +6 -0
  81. package/dist/types/core/routing/validation.d.ts +2 -0
  82. package/dist/types/integrations/index.d.ts +8 -1
  83. package/dist/types/runtime/client/events.d.ts +2 -0
  84. package/dist/types/runtime/client/only.d.ts +2 -2
  85. package/dist/types/runtime/client/visible.d.ts +1 -1
  86. package/dist/types/runtime/server/index.d.ts +5 -2
  87. package/dist/types/runtime/server/shorthash.d.ts +31 -0
  88. package/dist/types/vite-plugin-astro/compile.d.ts +9 -3
  89. package/dist/types/vite-plugin-build-css/index.d.ts +1 -4
  90. package/dist/types/vite-plugin-utils/index.d.ts +5 -0
  91. package/dist/vite-plugin-astro/compile.js +13 -6
  92. package/dist/vite-plugin-astro/hmr.js +19 -14
  93. package/dist/vite-plugin-astro/index.js +51 -24
  94. package/dist/vite-plugin-astro-server/index.js +64 -12
  95. package/dist/vite-plugin-build-css/index.js +92 -157
  96. package/dist/vite-plugin-env/index.js +7 -3
  97. package/dist/vite-plugin-jsx/index.js +3 -2
  98. package/dist/vite-plugin-markdown/index.js +52 -31
  99. package/dist/vite-plugin-utils/index.js +13 -0
  100. package/env.d.ts +18 -2
  101. package/package.json +48 -47
  102. package/dist/core/build/types.d.js +0 -0
  103. package/dist/core/render/pretty-feed.js +0 -103
  104. package/dist/core/render/rss.js +0 -119
  105. package/dist/types/core/render/pretty-feed.d.ts +0 -2
  106. package/dist/types/core/render/rss.d.ts +0 -14
  107. package/dist/types/vite-plugin-build-html/add-rollup-input.d.ts +0 -2
  108. package/dist/types/vite-plugin-build-html/extract-assets.d.ts +0 -20
  109. package/dist/types/vite-plugin-build-html/index.d.ts +0 -18
  110. package/dist/types/vite-plugin-build-html/util.d.ts +0 -7
  111. package/dist/vite-plugin-build-html/add-rollup-input.js +0 -50
  112. package/dist/vite-plugin-build-html/extract-assets.js +0 -202
  113. package/dist/vite-plugin-build-html/index.js +0 -426
  114. package/dist/vite-plugin-build-html/util.js +0 -44
package/LICENSE ADDED
@@ -0,0 +1,61 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 Fred K. Schott
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
22
+
23
+
24
+ """
25
+ This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
26
+
27
+ Copyright (c) 2020 [these people](https://github.com/sveltejs/kit/graphs/contributors)
28
+
29
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
30
+
31
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
32
+
33
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
34
+ """
35
+
36
+
37
+ """
38
+ This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
39
+
40
+ MIT License
41
+
42
+ Copyright (c) 2019-present, Yuxi (Evan) You and Vite contributors
43
+
44
+ Permission is hereby granted, free of charge, to any person obtaining a copy
45
+ of this software and associated documentation files (the "Software"), to deal
46
+ in the Software without restriction, including without limitation the rights
47
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
48
+ copies of the Software, and to permit persons to whom the Software is
49
+ furnished to do so, subject to the following conditions:
50
+
51
+ The above copyright notice and this permission notice shall be included in all
52
+ copies or substantial portions of the Software.
53
+
54
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
55
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
56
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
57
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
58
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
59
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
60
+ SOFTWARE.
61
+ """
package/README.md CHANGED
@@ -1,106 +1,46 @@
1
- <a href="https://astro.build">
2
- <img src="https://raw.githubusercontent.com/withastro/astro/main/assets/social/banner.svg" />
3
- </a>
1
+ <br/>
2
+ <p align="center">
3
+ <img src="../../assets/social/banner-minimal.png" alt="Astro logo">
4
+ <br/><br/>
5
+ <a href="https://astro.build">Astro</a> is a website build tool for the modern web &mdash;
6
+ <br/>
7
+ powerful developer experience meets lightweight output.
8
+ <br/><br/>
9
+ </p>
4
10
 
5
- <div center>
6
11
 
7
- **Astro** is a new kind of static site builder for the modern web&mdash;powerful developer experience meets lightweight output.
12
+ ## Install
8
13
 
9
- </div>
10
14
 
11
- ### [🚀 Read the launch post →](https://astro.build/blog/introducing-astro)
15
+ ```bash
16
+ # Recommended!
17
+ npm create astro@latest
12
18
 
13
- ### [📚 Learn Astro →](https://docs.astro.build/en/getting-started/)
19
+ # Manual:
20
+ npm install --save-dev astro
21
+ ```
14
22
 
15
- ## Project Status
23
+ Looking for help? Start with our [Getting Started](https://docs.astro.build/en/getting-started/) guide.
16
24
 
17
- ⚠️ **Astro is still beta software&mdash;missing features and bugs are to be expected!** We are quickly working our way towards a stable, production-ready v1.0 release, but we are still finalizing some of Astro's APIs.
25
+ Looking for quick examples? [Open a starter project](https://astro.new/) right in your browser.
18
26
 
19
- That being said, there are quite a few Astro sites in production already. We're incredibly grateful to everyone who has made an early bet on Astro!
27
+ ## Documentation
20
28
 
21
- ## Quick Start
29
+ Visit our [offical documentation](https://docs.astro.build/).
22
30
 
23
- <table>
24
- <tbody>
25
- <tr>
26
- <td>
27
- <img width="441" height="1px">
28
- <strong>👾 Online</strong>
29
- </td>
30
- <td>
31
- <img width="441" height="1px">
32
- <strong>📦 Local</strong>
33
- </td>
34
- </tr>
35
- <tr>
36
- <td>
31
+ ## Support
37
32
 
38
- Try Astro in your browser!
33
+ Having trouble? Get help in the official [Astro Discord](https://astro.build/chat).
34
+ ## Contributing
39
35
 
40
- [Launch astro.new →](https://astro.new)
36
+ **New contributors welcome!** Check out our [Contributors Guide](CONTRIBUTING.md) for help getting started.
41
37
 
42
- </td>
43
- <td>
38
+ Join us on [Discord](https://astro.build/chat) to meet other maintainers. We'll help you get your first contribution in no time!
44
39
 
45
- Get started with Astro using our interactive CLI!
40
+ ## Sponsors
46
41
 
47
- ```bash
48
- npm init astro my-astro-project
49
- ```
42
+ Astro is generously supported by [Netlify](https://www.netlify.com/), [Vercel](https://vercel.com/), and several other amazing organizations [listed here.](https://astro.build/)
50
43
 
51
- </td>
52
- </tr>
53
- </tbody>
54
- </table>
44
+ [❤️ Sponsor Astro! ❤️](https://github.com/withastro/astro/blob/main/FUNDING.md)
55
45
 
56
- ## Sponsors
57
46
 
58
- You can sponsor Astro's development on [Open Collective](https://opencollective.com/astrodotbuild). Astro is generously supported by the following companies and individuals:
59
-
60
- ### Platinum Sponsors
61
-
62
- <table>
63
- <tbody>
64
- <tr>
65
- <td align="center"><a href="https://www.netlify.com/#gh-light-mode-only" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify.svg#gh-light-mode-only" alt="Netlify" /></a><a href="https://www.netlify.com/#gh-dark-mode-only" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/netlify-dark.svg#gh-dark-mode-only" alt="Netlify" />
66
- </a></td>
67
- <td align="center"><a href="https://www.vercel.com/#gh-light-mode-only" target="_blank"><img width="150" height="34" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel.svg#gh-light-mode-only" alt="Vercel" /></a><a href="https://www.vercel.com/#gh-dark-mode-only"><img width="150" height="34" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/vercel-dark.svg#gh-dark-mode-only" alt="Vercel" />
68
- </a></td>
69
- </tr>
70
- </tbody>
71
- </table>
72
-
73
- ### Gold Sponsors
74
-
75
- <table>
76
- <tbody>
77
- <tr>
78
- <td align="center">
79
- <a href="https://divRIOTS.com#gh-light-mode-only" target="_blank">
80
- <img width="150" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots.svg#gh-light-mode-only" alt="‹div›RIOTS" />
81
- </a>
82
- <a href="https://divRIOTS.com#gh-dark-mode-only" target="_blank">
83
- <img width="150" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/divriots-dark.svg#gh-dark-mode-only" alt="‹div›RIOTS" />
84
- </a>
85
- </td>
86
- <td align="center">
87
- <a href="https://stackupdigital.co.uk/#gh-light-mode-only" target="_blank">
88
- <img width="162" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup.svg#gh-light-mode-only" alt="StackUp Digital" />
89
- </a>
90
- <a href="https://stackupdigital.co.uk/#gh-dark-mode-only" target="_blank">
91
- <img width="130" height="32" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/stackup-dark.svg#gh-dark-mode-only" alt="StackUp Digital" />
92
- </a>
93
- </td>
94
- </tr>
95
- </tbody>
96
- </table>
97
-
98
- ### Sponsors
99
-
100
- <table>
101
- <tbody>
102
- <tr>
103
- <td align="center"><a href="https://sentry.io" target="_blank"><img width="147" height="40" src="https://raw.githubusercontent.com/withastro/astro/main/.github/assets/sentry.svg" alt="Sentry" /></a></td><td align="center"><a href="https://qoddi.com" target="_blank"><img width="147" height="40" src="https://devcenter.qoddi.com/wp-content/uploads/2021/11/blog-transparent-logo-1.png" alt="Qoddi App Platform" /></a></td>
104
- </tr>
105
- </tbody>
106
- </table>
package/astro-jsx.d.ts CHANGED
@@ -621,7 +621,10 @@ declare namespace astroHTML.JSX {
621
621
  // - "number | string"
622
622
  // - "string"
623
623
  // - union of string literals
624
- interface SVGAttributes<T extends EventTarget> extends AriaAttributes, DOMAttributes<T> {
624
+ interface SVGAttributes<T extends EventTarget>
625
+ extends AriaAttributes,
626
+ DOMAttributes<T>,
627
+ AstroBuiltinAttributes {
625
628
  // Attributes which also defined in HTMLAttributes
626
629
  className?: string | undefined | null;
627
630
  class?: string | undefined | null;
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  import type * as shiki from 'shiki';
3
- import { getHighlighter } from 'shiki';
3
+ import { getHighlighter } from './Shiki.js';
4
4
 
5
5
  export interface Props {
6
6
  /** The code to highlight. Required. */
@@ -3,6 +3,13 @@ export interface Props {
3
3
  content?: string;
4
4
  }
5
5
 
6
+ // NOTE(fks): We are most likely moving this component out of Astro core
7
+ // in a few weeks. Checking the name like this is a bit of a hack, but we
8
+ // intentionally don't want to add an SSR flag for others to read from, just yet.
9
+ if (Astro.redirect.name !== '_onlyAvailableInSSR') {
10
+ console.error(`\x1B[31mThe <Markdown> component is not available in SSR. See https://github.com/withastro/rfcs/discussions/179 for more info.\x1B[39m`);
11
+ }
12
+
6
13
  const dedent = (str: string) => {
7
14
  const _str = str.split('\n').filter(s => s.trimStart().length > 0);
8
15
  if (_str.length === 0) {
@@ -0,0 +1,24 @@
1
+ import { getHighlighter as getShikiHighlighter } from 'shiki';
2
+
3
+ // Caches Promise<Highligher> for reuse when the same theme and langs are provided
4
+ const _resolvedHighlighters = new Map();
5
+
6
+ function stringify(opts) {
7
+ // Always sort keys before stringifying to make sure objects match regardless of parameter ordering
8
+ return JSON.stringify(opts, Object.keys(opts).sort());
9
+ }
10
+
11
+ export function getHighlighter(opts) {
12
+ const key = stringify(opts);
13
+
14
+ // Highlighter has already been requested, reuse the same instance
15
+ if (_resolvedHighlighters.has(key)) {
16
+ return _resolvedHighlighters.get(key);
17
+ }
18
+
19
+ // Start the async getHighlighter call and cache the Promise
20
+ const highlighter = getShikiHighlighter(opts);
21
+ _resolvedHighlighters.set(key, highlighter);
22
+
23
+ return highlighter;
24
+ }
package/dist/cli/index.js CHANGED
@@ -1,6 +1,8 @@
1
1
  import * as colors from "kleur/colors";
2
2
  import yargs from "yargs-parser";
3
3
  import { z } from "zod";
4
+ import { AstroTelemetry } from "@astrojs/telemetry";
5
+ import * as event from "@astrojs/telemetry/events";
4
6
  import { nodeLogDestination, enableVerboseLogging } from "../core/logger/node.js";
5
7
  import build from "../core/build/index.js";
6
8
  import add from "../core/add/index.js";
@@ -8,7 +10,8 @@ import devServer from "../core/dev/index.js";
8
10
  import preview from "../core/preview/index.js";
9
11
  import { check } from "./check.js";
10
12
  import { openInBrowser } from "./open.js";
11
- import { loadConfig } from "../core/config.js";
13
+ import * as telemetryHandler from "./telemetry.js";
14
+ import { openConfig } from "../core/config.js";
12
15
  import { printHelp, formatErrorMessage, formatConfigErrorMessage } from "../core/messages.js";
13
16
  import { createSafeError } from "../core/util.js";
14
17
  function printAstroHelp() {
@@ -22,6 +25,7 @@ function printAstroHelp() {
22
25
  ["build", "Build a pre-compiled production-ready site."],
23
26
  ["preview", "Preview your build locally before deploying."],
24
27
  ["check", "Check your project for errors."],
28
+ ["telemetry", "Enable/disable anonymous data collection."],
25
29
  ["--version", "Show the version number and exit."],
26
30
  ["--help", "Show this help message."]
27
31
  ],
@@ -29,8 +33,6 @@ function printAstroHelp() {
29
33
  ["--host [optional IP]", "Expose server on network"],
30
34
  ["--config <path>", "Specify the path to the Astro config file."],
31
35
  ["--root <path>", "Specify the path to the project root folder."],
32
- ["--legacy-build", "Use the build strategy prior to 0.24.0"],
33
- ["--experimental-ssr", "Enable SSR compilation fot 3rd-party adapters."],
34
36
  ["--drafts", "Include markdown draft pages in the build."],
35
37
  ["--verbose", "Enable verbose logging"],
36
38
  ["--silent", "Disable logging"]
@@ -38,7 +40,7 @@ function printAstroHelp() {
38
40
  });
39
41
  }
40
42
  async function printVersion() {
41
- const version = "1.0.0-beta.4";
43
+ const version = "1.0.0-beta.40";
42
44
  console.log();
43
45
  console.log(` ${colors.bgGreen(colors.black(` astro `))} ${colors.green(`v${version}`)}`);
44
46
  }
@@ -46,6 +48,8 @@ function resolveCommand(flags) {
46
48
  const cmd = flags._[2];
47
49
  if (cmd === "add")
48
50
  return "add";
51
+ if (cmd === "telemetry")
52
+ return "telemetry";
49
53
  if (flags.version)
50
54
  return "version";
51
55
  else if (flags.help)
@@ -57,6 +61,7 @@ function resolveCommand(flags) {
57
61
  return "help";
58
62
  }
59
63
  async function cli(args) {
64
+ var _a;
60
65
  const flags = yargs(args);
61
66
  const cmd = resolveCommand(flags);
62
67
  const root = flags.root;
@@ -78,24 +83,33 @@ async function cli(args) {
78
83
  } else if (flags.silent) {
79
84
  logging.level = "silent";
80
85
  }
81
- let config;
82
- try {
83
- config = await loadConfig({ cwd: root, flags, cmd });
84
- } catch (err) {
85
- return throwAndExit(err);
86
+ const telemetry = new AstroTelemetry({ version: "1.0.0-beta.40" });
87
+ if (cmd === "telemetry") {
88
+ try {
89
+ const subcommand = (_a = flags._[3]) == null ? void 0 : _a.toString();
90
+ return await telemetryHandler.update(subcommand, { flags, telemetry });
91
+ } catch (err) {
92
+ return throwAndExit(err);
93
+ }
86
94
  }
87
95
  switch (cmd) {
88
96
  case "add": {
89
97
  try {
90
98
  const packages = flags._.slice(3);
91
- return await add(packages, { cwd: root, flags, logging });
99
+ telemetry.record(event.eventCliSession({
100
+ astroVersion: "1.0.0-beta.40",
101
+ cliCommand: "add"
102
+ }));
103
+ return await add(packages, { cwd: root, flags, logging, telemetry });
92
104
  } catch (err) {
93
105
  return throwAndExit(err);
94
106
  }
95
107
  }
96
108
  case "dev": {
97
109
  try {
98
- await devServer(config, { logging });
110
+ const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
111
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.40", cliCommand: "dev" }, userConfig, flags));
112
+ await devServer(astroConfig, { logging, telemetry });
99
113
  return await new Promise(() => {
100
114
  });
101
115
  } catch (err) {
@@ -104,18 +118,24 @@ async function cli(args) {
104
118
  }
105
119
  case "build": {
106
120
  try {
107
- return await build(config, { logging });
121
+ const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
122
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.40", cliCommand: "build" }, userConfig, flags));
123
+ return await build(astroConfig, { logging, telemetry });
108
124
  } catch (err) {
109
125
  return throwAndExit(err);
110
126
  }
111
127
  }
112
128
  case "check": {
113
- const ret = await check(config);
129
+ const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
130
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.40", cliCommand: "check" }, userConfig, flags));
131
+ const ret = await check(astroConfig);
114
132
  return process.exit(ret);
115
133
  }
116
134
  case "preview": {
117
135
  try {
118
- const server = await preview(config, { logging });
136
+ const { astroConfig, userConfig } = await openConfig({ cwd: root, flags, cmd });
137
+ telemetry.record(event.eventCliSession({ astroVersion: "1.0.0-beta.40", cliCommand: "preview" }, userConfig, flags));
138
+ const server = await preview(astroConfig, { logging, telemetry });
119
139
  return await server.closed();
120
140
  } catch (err) {
121
141
  return throwAndExit(err);
@@ -123,6 +143,10 @@ async function cli(args) {
123
143
  }
124
144
  case "docs": {
125
145
  try {
146
+ await telemetry.record(event.eventCliSession({
147
+ astroVersion: "1.0.0-beta.40",
148
+ cliCommand: "docs"
149
+ }));
126
150
  return await openInBrowser("https://docs.astro.build/");
127
151
  } catch (err) {
128
152
  return throwAndExit(err);
@@ -0,0 +1,36 @@
1
+ import * as msg from "../core/messages.js";
2
+ async function update(subcommand, { flags, telemetry }) {
3
+ const isValid = ["enable", "disable", "reset"].includes(subcommand);
4
+ if (flags.help || !isValid) {
5
+ msg.printHelp({
6
+ commandName: "astro telemetry",
7
+ usage: "<enable|disable|reset>",
8
+ commands: [
9
+ ["enable", "Enable anonymous data collection."],
10
+ ["disable", "Disable anonymous data collection."],
11
+ ["reset", "Reset anonymous data collection settings."]
12
+ ]
13
+ });
14
+ return;
15
+ }
16
+ switch (subcommand) {
17
+ case "enable": {
18
+ telemetry.setEnabled(true);
19
+ console.log(msg.telemetryEnabled());
20
+ return;
21
+ }
22
+ case "disable": {
23
+ telemetry.setEnabled(false);
24
+ console.log(msg.telemetryDisabled());
25
+ return;
26
+ }
27
+ case "reset": {
28
+ telemetry.clear();
29
+ console.log(msg.telemetryReset());
30
+ return;
31
+ }
32
+ }
33
+ }
34
+ export {
35
+ update
36
+ };
@@ -20,7 +20,7 @@ const CONFIG_STUB = `import { defineConfig } from 'astro/config';
20
20
 
21
21
  export default defineConfig({});`;
22
22
  const TAILWIND_CONFIG_STUB = `module.exports = {
23
- content: ['./src/**/*.{astro,html,js,jsx,svelte,ts,tsx,vue}'],
23
+ content: ['./src/**/*.{astro,html,js,jsx,md,svelte,ts,tsx,vue}'],
24
24
  theme: {
25
25
  extend: {},
26
26
  },
@@ -18,7 +18,8 @@ import { parseNpmName } from "../util.js";
18
18
  import { wrapDefaultExport } from "./wrapper.js";
19
19
  import { ensureImport } from "./imports.js";
20
20
  import { t, parse, visit, generate } from "./babel.js";
21
- async function add(names, { cwd, flags, logging }) {
21
+ import { appendForwardSlash } from "../path.js";
22
+ async function add(names, { cwd, flags, logging, telemetry }) {
22
23
  if (flags.help) {
23
24
  printHelp({
24
25
  commandName: "astro add",
@@ -65,7 +66,7 @@ async function add(names, { cwd, flags, logging }) {
65
66
  debug("add", `Found config at ${configURL}`);
66
67
  } else {
67
68
  info(logging, "add", `Unable to locate a config file, generating one for you.`);
68
- configURL = new URL("./astro.config.mjs", root);
69
+ configURL = new URL("./astro.config.mjs", appendForwardSlash(root.href));
69
70
  await fs.writeFile(fileURLToPath(configURL), CONSTS.CONFIG_STUB, { encoding: "utf-8" });
70
71
  }
71
72
  const integrations = await validateIntegrations(names);
@@ -27,7 +27,9 @@ function deserializeManifest(serializedManifest) {
27
27
  const route = serializedRoute;
28
28
  route.routeData = deserializeRouteData(serializedRoute.routeData);
29
29
  }
30
+ const assets = new Set(serializedManifest.assets);
30
31
  return __spreadProps(__spreadValues({}, serializedManifest), {
32
+ assets,
31
33
  routes
32
34
  });
33
35
  }
@@ -32,7 +32,9 @@ import {
32
32
  createLinkStylesheetElementSet,
33
33
  createModuleScriptElementWithSrcSet
34
34
  } from "../render/ssr-element.js";
35
- import { prependForwardSlash } from "../path.js";
35
+ import { joinPaths, prependForwardSlash } from "../path.js";
36
+ const pagesVirtualModuleId = "@astrojs-pages-virtual-entry";
37
+ const resolvedPagesVirtualModuleId = "\0" + pagesVirtualModuleId;
36
38
  class App {
37
39
  constructor(manifest) {
38
40
  __privateAdd(this, _renderPage);
@@ -90,12 +92,20 @@ renderPage_fn = async function(request, routeData, mod) {
90
92
  const renderers = manifest.renderers;
91
93
  const info = __privateGet(this, _routeDataToRouteInfo).get(routeData);
92
94
  const links = createLinkStylesheetElementSet(info.links, manifest.site);
93
- const scripts = createModuleScriptElementWithSrcSet(info.scripts, manifest.site);
95
+ const filteredScripts = info.scripts.filter((script) => typeof script !== "string" && (script == null ? void 0 : script.stage) !== "head-inline");
96
+ const scripts = createModuleScriptElementWithSrcSet(filteredScripts, manifest.site);
97
+ for (const script of info.scripts) {
98
+ if (typeof script !== "string" && script.stage === "head-inline") {
99
+ scripts.add({
100
+ props: {},
101
+ children: script.children
102
+ });
103
+ }
104
+ }
94
105
  const result = await render({
95
- legacyBuild: false,
96
106
  links,
97
107
  logging: __privateGet(this, _logging),
98
- markdownRender: manifest.markdown.render,
108
+ markdown: manifest.markdown,
99
109
  mod,
100
110
  origin: url.origin,
101
111
  pathname: url.pathname,
@@ -106,7 +116,7 @@ renderPage_fn = async function(request, routeData, mod) {
106
116
  throw new Error(`Unable to resolve [${specifier}]`);
107
117
  }
108
118
  const bundlePath = manifest.entryModules[specifier];
109
- return bundlePath.startsWith("data:") ? bundlePath : prependForwardSlash(bundlePath);
119
+ return bundlePath.startsWith("data:") ? bundlePath : prependForwardSlash(joinPaths(manifest.base, bundlePath));
110
120
  },
111
121
  route: routeData,
112
122
  routeCache: __privateGet(this, _routeCache),
@@ -118,14 +128,12 @@ renderPage_fn = async function(request, routeData, mod) {
118
128
  return result.response;
119
129
  }
120
130
  let html = result.html;
131
+ let init = result.response;
132
+ let headers = init.headers;
121
133
  let bytes = __privateGet(this, _encoder).encode(html);
122
- return new Response(bytes, {
123
- status: 200,
124
- headers: {
125
- "Content-Type": "text/html",
126
- "Content-Length": bytes.byteLength.toString()
127
- }
128
- });
134
+ headers.set("Content-Type", "text/html");
135
+ headers.set("Content-Length", bytes.byteLength.toString());
136
+ return new Response(bytes, init);
129
137
  };
130
138
  _callEndpoint = new WeakSet();
131
139
  callEndpoint_fn = async function(request, routeData, mod) {
@@ -159,5 +167,7 @@ callEndpoint_fn = async function(request, routeData, mod) {
159
167
  };
160
168
  export {
161
169
  App,
162
- deserializeManifest
170
+ deserializeManifest,
171
+ pagesVirtualModuleId,
172
+ resolvedPagesVirtualModuleId
163
173
  };
@@ -1,10 +1,9 @@
1
- import astroRemark from "@astrojs/markdown-remark";
2
1
  import fs from "fs";
3
2
  import { bgGreen, black, cyan, dim, green, magenta } from "kleur/colors";
4
3
  import npath from "path";
5
4
  import { fileURLToPath } from "url";
6
5
  import { debug, info } from "../logger/core.js";
7
- import { prependForwardSlash } from "../../core/path.js";
6
+ import { joinPaths, prependForwardSlash, removeLeadingForwardSlash } from "../../core/path.js";
8
7
  import { BEFORE_HYDRATION_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
9
8
  import { call as callEndpoint } from "../endpoint/index.js";
10
9
  import { render } from "../render/core.js";
@@ -99,13 +98,14 @@ function addPageName(pathname, opts) {
99
98
  opts.pageNames.push(pathname.replace(/\/?$/, "/").replace(/^\//, ""));
100
99
  }
101
100
  async function generatePath(pathname, opts, gopts) {
101
+ var _a;
102
102
  const { astroConfig, logging, origin, routeCache } = opts;
103
103
  const { mod, internals, linkIds, hoistedId, pageData, renderers } = gopts;
104
104
  if (pageData.route.type === "page") {
105
105
  addPageName(pathname, opts);
106
106
  }
107
107
  debug("build", `Generating: ${pathname}`);
108
- const site = astroConfig.site;
108
+ const site = astroConfig.base !== "/" ? joinPaths(((_a = astroConfig.site) == null ? void 0 : _a.toString()) || "http://localhost/", astroConfig.base) : astroConfig.site;
109
109
  const links = createLinkStylesheetElementSet(linkIds.reverse(), site);
110
110
  const scripts = createModuleScriptElementWithSrcSet(hoistedId ? [hoistedId] : [], site);
111
111
  for (const script of astroConfig._ctx.scripts) {
@@ -116,12 +116,12 @@ async function generatePath(pathname, opts, gopts) {
116
116
  });
117
117
  }
118
118
  }
119
- const url = new URL(origin + pathname);
119
+ const ssr = isBuildingToSSR(opts.astroConfig);
120
+ const url = new URL(opts.astroConfig.base + removeLeadingForwardSlash(pathname), origin);
120
121
  const options = {
121
- legacyBuild: false,
122
122
  links,
123
123
  logging,
124
- markdownRender: [astroRemark, astroConfig.markdown],
124
+ markdown: astroConfig.markdown,
125
125
  mod,
126
126
  origin,
127
127
  pathname,
@@ -135,15 +135,13 @@ async function generatePath(pathname, opts, gopts) {
135
135
  }
136
136
  throw new Error(`Cannot find the built path for ${specifier}`);
137
137
  }
138
- const relPath = npath.posix.relative(pathname, "/" + hashedFilePath);
139
- const fullyRelativePath = relPath[0] === "." ? relPath : "./" + relPath;
140
- return fullyRelativePath;
138
+ return prependForwardSlash(npath.posix.join(astroConfig.base, hashedFilePath));
141
139
  },
142
- request: createRequest({ url, headers: new Headers(), logging }),
140
+ request: createRequest({ url, headers: new Headers(), logging, ssr }),
143
141
  route: pageData.route,
144
142
  routeCache,
145
143
  site: astroConfig.site ? new URL(astroConfig.base, astroConfig.site).toString() : astroConfig.site,
146
- ssr: isBuildingToSSR(opts.astroConfig)
144
+ ssr
147
145
  };
148
146
  let body;
149
147
  if (pageData.route.type === "endpoint") {
@@ -161,6 +159,7 @@ async function generatePath(pathname, opts, gopts) {
161
159
  }
162
160
  const outFolder = getOutFolder(astroConfig, pathname, pageData.route.type);
163
161
  const outFile = getOutFile(astroConfig, outFolder, pathname, pageData.route.type);
162
+ pageData.route.distURL = outFile;
164
163
  await fs.promises.mkdir(outFolder, { recursive: true });
165
164
  await fs.promises.writeFile(outFile, body, "utf-8");
166
165
  }
@@ -11,7 +11,6 @@ import {
11
11
  timerMessage,
12
12
  warnIfUsingExperimentalSSR
13
13
  } from "../logger/core.js";
14
- import { nodeLogOptions } from "../logger/node.js";
15
14
  import { createRouteManifest } from "../routing/index.js";
16
15
  import { collectPagesData } from "./page-data.js";
17
16
  import { staticBuild } from "./static-build.js";
@@ -25,7 +24,7 @@ import {
25
24
  import { getTimeStat } from "./util.js";
26
25
  import { createSafeError, isBuildingToSSR } from "../util.js";
27
26
  import { fixViteErrorMessage } from "../errors.js";
28
- async function build(config, options = { logging: nodeLogOptions }) {
27
+ async function build(config, options) {
29
28
  applyPolyfill();
30
29
  const builder = new AstroBuilder(config, options);
31
30
  await builder.run();
@@ -141,7 +140,6 @@ class AstroBuilder {
141
140
  try {
142
141
  await this.build(setupData);
143
142
  } catch (_err) {
144
- debugger;
145
143
  throw fixViteErrorMessage(createSafeError(_err), setupData.viteServer);
146
144
  }
147
145
  }
@@ -151,7 +149,6 @@ class AstroBuilder {
151
149
  pageCount,
152
150
  buildMode
153
151
  }) {
154
- const buildTime = performance.now() - timeStart;
155
152
  const total = getTimeStat(timeStart, performance.now());
156
153
  let messages = [];
157
154
  if (buildMode === "static") {