astro 2.9.7 → 3.0.0-beta.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 (161) hide show
  1. package/astro.js +2 -2
  2. package/components/ViewTransitions.astro +65 -12
  3. package/dist/@types/astro.d.ts +68 -7
  4. package/dist/@types/astro.js +1 -0
  5. package/dist/assets/generate.js +7 -3
  6. package/dist/assets/image-endpoint.d.ts +1 -1
  7. package/dist/assets/image-endpoint.js +3 -3
  8. package/dist/assets/internal.js +1 -2
  9. package/dist/assets/services/noop.d.ts +3 -0
  10. package/dist/assets/services/noop.js +17 -0
  11. package/dist/assets/services/vendor/squoosh/image_data.js +3 -0
  12. package/dist/assets/services/vendor/squoosh/impl.js +2 -3
  13. package/dist/assets/services/vendor/squoosh/utils/workerPool.js +4 -0
  14. package/dist/assets/vendor/image-size/types/tiff.js +1 -1
  15. package/dist/assets/vendor/queue/queue.d.ts +3 -3
  16. package/dist/assets/vite-plugin-assets.d.ts +1 -1
  17. package/dist/assets/vite-plugin-assets.js +1 -23
  18. package/dist/cli/add/index.js +6 -9
  19. package/dist/cli/build/index.js +1 -1
  20. package/dist/cli/check/index.d.ts +2 -78
  21. package/dist/cli/check/index.js +23 -275
  22. package/dist/cli/dev/index.js +1 -1
  23. package/dist/cli/index.js +7 -13
  24. package/dist/cli/info/index.js +3 -4
  25. package/dist/cli/install-package.d.ts +7 -0
  26. package/dist/cli/install-package.js +102 -0
  27. package/dist/cli/preview/index.js +1 -1
  28. package/dist/cli/sync/index.js +1 -1
  29. package/dist/content/runtime-assets.js +1 -2
  30. package/dist/content/runtime.js +3 -5
  31. package/dist/content/server-listeners.js +1 -2
  32. package/dist/content/types-generator.js +8 -8
  33. package/dist/content/utils.js +3 -4
  34. package/dist/content/vite-plugin-content-assets.js +4 -6
  35. package/dist/content/vite-plugin-content-imports.js +1 -1
  36. package/dist/content/vite-plugin-content-virtual-mod.js +5 -6
  37. package/dist/core/app/index.js +5 -3
  38. package/dist/core/app/node.d.ts +1 -1
  39. package/dist/core/app/node.js +7 -2
  40. package/dist/core/build/css-asset-name.js +2 -4
  41. package/dist/core/build/generate.js +10 -17
  42. package/dist/core/build/graph.js +3 -4
  43. package/dist/core/build/index.js +8 -1
  44. package/dist/core/build/internal.js +2 -2
  45. package/dist/core/build/plugin.js +2 -4
  46. package/dist/core/build/plugins/plugin-analyzer.js +6 -9
  47. package/dist/core/build/plugins/plugin-component-entry.js +2 -4
  48. package/dist/core/build/plugins/plugin-css.js +6 -9
  49. package/dist/core/build/plugins/plugin-hoisted-scripts.js +2 -3
  50. package/dist/core/build/plugins/plugin-internals.js +1 -2
  51. package/dist/core/build/plugins/plugin-pages.js +5 -1
  52. package/dist/core/build/plugins/plugin-ssr.js +12 -8
  53. package/dist/core/build/static-build.js +8 -12
  54. package/dist/core/client-directive/build.js +1 -2
  55. package/dist/core/compile/compile.js +2 -1
  56. package/dist/core/compile/style.js +2 -3
  57. package/dist/core/config/schema.d.ts +8 -0
  58. package/dist/core/config/schema.js +11 -3
  59. package/dist/core/config/settings.js +3 -3
  60. package/dist/core/config/timer.js +5 -6
  61. package/dist/core/constants.js +1 -1
  62. package/dist/core/cookies/cookies.d.ts +5 -5
  63. package/dist/core/cookies/cookies.js +9 -9
  64. package/dist/core/create-vite.js +6 -28
  65. package/dist/core/dev/container.d.ts +0 -1
  66. package/dist/core/dev/container.js +0 -5
  67. package/dist/core/dev/dev.js +2 -3
  68. package/dist/core/dev/index.d.ts +1 -1
  69. package/dist/core/dev/index.js +1 -2
  70. package/dist/core/dev/restart.d.ts +1 -4
  71. package/dist/core/dev/restart.js +15 -19
  72. package/dist/core/endpoint/dev/index.js +1 -1
  73. package/dist/core/endpoint/index.js +3 -4
  74. package/dist/core/errors/dev/utils.js +12 -16
  75. package/dist/core/errors/dev/vite.js +11 -13
  76. package/dist/core/errors/errors-data.d.ts +21 -0
  77. package/dist/core/errors/errors-data.js +21 -0
  78. package/dist/core/errors/errors.js +12 -17
  79. package/dist/core/errors/overlay.js +7 -8
  80. package/dist/core/errors/utils.js +1 -1
  81. package/dist/core/fs/index.js +1 -1
  82. package/dist/core/logger/console.js +1 -1
  83. package/dist/core/logger/core.d.ts +26 -6
  84. package/dist/core/logger/core.js +54 -8
  85. package/dist/core/logger/node.d.ts +4 -4
  86. package/dist/core/logger/node.js +6 -6
  87. package/dist/core/messages.js +4 -5
  88. package/dist/core/module-loader/vite.js +2 -2
  89. package/dist/core/polyfill.js +12 -4
  90. package/dist/core/redirects/helpers.js +3 -3
  91. package/dist/core/render/core.js +1 -4
  92. package/dist/core/render/params-and-props.js +2 -3
  93. package/dist/core/render/result.js +1 -2
  94. package/dist/core/render/route-cache.d.ts +1 -2
  95. package/dist/core/render/route-cache.js +6 -11
  96. package/dist/core/routing/manifest/create.js +2 -6
  97. package/dist/core/routing/params.js +1 -1
  98. package/dist/core/routing/validation.js +7 -8
  99. package/dist/core/sync/index.js +1 -1
  100. package/dist/core/util.js +1 -1
  101. package/dist/events/error.js +1 -1
  102. package/dist/events/session.js +12 -13
  103. package/dist/integrations/astroFeaturesValidation.d.ts +14 -0
  104. package/dist/integrations/astroFeaturesValidation.js +109 -0
  105. package/dist/integrations/index.d.ts +3 -1
  106. package/dist/integrations/index.js +96 -31
  107. package/dist/jsx/babel.js +1 -2
  108. package/dist/prerender/metadata.js +1 -2
  109. package/dist/runtime/client/hmr.js +1 -2
  110. package/dist/runtime/server/astro-component.js +1 -2
  111. package/dist/runtime/server/astro-island.js +53 -55
  112. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  113. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  114. package/dist/runtime/server/endpoint.d.ts +2 -1
  115. package/dist/runtime/server/endpoint.js +21 -27
  116. package/dist/runtime/server/hydration.js +9 -0
  117. package/dist/runtime/server/jsx.js +3 -2
  118. package/dist/runtime/server/render/astro/instance.js +6 -3
  119. package/dist/runtime/server/render/astro/render-template.js +4 -3
  120. package/dist/runtime/server/render/astro/render.js +3 -3
  121. package/dist/runtime/server/render/common.js +1 -1
  122. package/dist/runtime/server/render/component.js +11 -13
  123. package/dist/runtime/server/render/dom.js +1 -1
  124. package/dist/runtime/server/render/page.js +2 -3
  125. package/dist/runtime/server/render/slot.js +2 -1
  126. package/dist/runtime/server/render/util.js +1 -2
  127. package/dist/runtime/server/transition.d.ts +1 -0
  128. package/dist/runtime/server/transition.js +1 -0
  129. package/dist/transitions/vite-plugin-transitions.js +1 -0
  130. package/dist/vite-plugin-astro/compile.js +2 -3
  131. package/dist/vite-plugin-astro/hmr.js +3 -5
  132. package/dist/vite-plugin-astro/index.js +1 -1
  133. package/dist/vite-plugin-astro/metadata.js +1 -2
  134. package/dist/vite-plugin-astro-postprocess/index.js +1 -1
  135. package/dist/vite-plugin-astro-server/base.js +1 -2
  136. package/dist/vite-plugin-astro-server/controller.js +2 -3
  137. package/dist/vite-plugin-astro-server/css.js +1 -1
  138. package/dist/vite-plugin-astro-server/request.js +1 -1
  139. package/dist/vite-plugin-astro-server/route.js +1 -2
  140. package/dist/vite-plugin-astro-server/scripts.js +2 -3
  141. package/dist/vite-plugin-astro-server/vite.js +1 -1
  142. package/dist/vite-plugin-config-alias/index.js +1 -1
  143. package/dist/vite-plugin-env/index.js +2 -2
  144. package/dist/vite-plugin-head/index.js +4 -6
  145. package/dist/vite-plugin-html/index.js +1 -2
  146. package/dist/vite-plugin-html/transform/index.js +1 -1
  147. package/dist/vite-plugin-html/transform/slots.js +5 -6
  148. package/dist/vite-plugin-html/transform/utils.js +1 -2
  149. package/dist/vite-plugin-jsx/import-source.js +1 -2
  150. package/dist/vite-plugin-jsx/index.js +1 -1
  151. package/dist/vite-plugin-jsx/tag.js +4 -6
  152. package/dist/vite-plugin-markdown/index.js +1 -2
  153. package/dist/vite-plugin-scanner/index.js +2 -1
  154. package/dist/vite-plugin-scanner/scan.js +1 -1
  155. package/dist/vite-plugin-scripts/index.js +1 -1
  156. package/dist/vite-plugin-scripts/page-ssr.js +2 -2
  157. package/package.json +13 -22
  158. package/tsconfigs/base.json +8 -6
  159. package/tsconfigs/strict.json +2 -3
  160. package/dist/cli/check/print.d.ts +0 -2
  161. package/dist/cli/check/print.js +0 -95
@@ -44,7 +44,7 @@ async function scan(code, id, settings) {
44
44
  message: AstroErrorData.InvalidPrerenderExport.message(
45
45
  prefix,
46
46
  suffix,
47
- (settings == null ? void 0 : settings.config.output) === "hybrid"
47
+ settings?.config.output === "hybrid"
48
48
  ),
49
49
  location: { file: id }
50
50
  });
@@ -29,7 +29,7 @@ function astroScriptsPlugin({ settings }) {
29
29
  },
30
30
  buildStart() {
31
31
  const hasHydrationScripts = settings.scripts.some((s) => s.stage === "before-hydration");
32
- if (hasHydrationScripts && (env == null ? void 0 : env.command) === "build" && !(env == null ? void 0 : env.ssrBuild)) {
32
+ if (hasHydrationScripts && env?.command === "build" && !env?.ssrBuild) {
33
33
  this.emitFile({
34
34
  type: "chunk",
35
35
  id: BEFORE_HYDRATION_SCRIPT_ID,
@@ -9,7 +9,7 @@ function astroScriptsPostPlugin({
9
9
  name: "astro:scripts:page-ssr",
10
10
  enforce: "post",
11
11
  transform(code, id, options) {
12
- if (!(options == null ? void 0 : options.ssr))
12
+ if (!options?.ssr)
13
13
  return;
14
14
  const hasInjectedScript = settings.scripts.some((s2) => s2.stage === "page-ssr");
15
15
  if (!hasInjectedScript)
@@ -29,7 +29,7 @@ function astroScriptsPostPlugin({
29
29
  `);
30
30
  return {
31
31
  code: s.toString(),
32
- map: s.generateMap({ hires: true })
32
+ map: s.generateMap({ hires: "boundary" })
33
33
  };
34
34
  }
35
35
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "2.9.7",
3
+ "version": "3.0.0-beta.0",
4
4
  "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
5
5
  "type": "module",
6
6
  "author": "withastro",
@@ -56,6 +56,7 @@
56
56
  "./assets/image-endpoint": "./dist/assets/image-endpoint.js",
57
57
  "./assets/services/sharp": "./dist/assets/services/sharp.js",
58
58
  "./assets/services/squoosh": "./dist/assets/services/squoosh.js",
59
+ "./assets/services/noop": "./dist/assets/services/noop.js",
59
60
  "./content/runtime": "./dist/content/runtime.js",
60
61
  "./content/runtime-assets": "./dist/content/runtime-assets.js",
61
62
  "./debug": "./components/Debug.astro",
@@ -102,12 +103,7 @@
102
103
  "vendor"
103
104
  ],
104
105
  "dependencies": {
105
- "@astrojs/compiler": "^1.6.3",
106
- "@astrojs/internal-helpers": "^0.1.1",
107
- "@astrojs/language-server": "^1.0.0",
108
- "@astrojs/markdown-remark": "^2.2.1",
109
- "@astrojs/telemetry": "^2.1.1",
110
- "@astrojs/webapi": "^2.2.0",
106
+ "@astrojs/compiler": "^1.8.0",
111
107
  "@babel/core": "^7.22.5",
112
108
  "@babel/generator": "^7.22.5",
113
109
  "@babel/parser": "^7.22.5",
@@ -128,8 +124,8 @@
128
124
  "devalue": "^4.3.2",
129
125
  "diff": "^5.1.0",
130
126
  "es-module-lexer": "^1.3.0",
131
- "esbuild": "^0.17.19",
132
- "estree-walker": "3.0.0",
127
+ "esbuild": "^0.18.16",
128
+ "estree-walker": "^3.0.3",
133
129
  "execa": "^6.1.0",
134
130
  "fast-glob": "^3.2.12",
135
131
  "github-slugger": "^2.0.0",
@@ -137,10 +133,11 @@
137
133
  "html-escaper": "^3.0.3",
138
134
  "js-yaml": "^4.1.0",
139
135
  "kleur": "^4.1.4",
140
- "magic-string": "^0.27.0",
136
+ "magic-string": "^0.30.2",
141
137
  "mime": "^3.0.0",
142
138
  "network-information-types": "^0.1.1",
143
139
  "ora": "^6.3.1",
140
+ "sharp": "^0.32.1",
144
141
  "p-limit": "^4.0.0",
145
142
  "path-to-regexp": "^6.2.1",
146
143
  "preferred-pm": "^3.0.3",
@@ -152,14 +149,16 @@
152
149
  "string-width": "^5.1.2",
153
150
  "strip-ansi": "^7.1.0",
154
151
  "tsconfig-resolver": "^3.0.1",
155
- "typescript": "*",
156
152
  "unist-util-visit": "^4.1.2",
157
153
  "vfile": "^5.3.7",
158
154
  "vite": "^4.4.6",
159
155
  "vitefu": "^0.2.4",
160
156
  "which-pm": "^2.0.0",
161
157
  "yargs-parser": "^21.1.1",
162
- "zod": "^3.20.6"
158
+ "zod": "^3.20.6",
159
+ "@astrojs/internal-helpers": "0.2.0-beta.0",
160
+ "@astrojs/markdown-remark": "3.0.0-beta.0",
161
+ "@astrojs/telemetry": "3.0.0-beta.0"
163
162
  },
164
163
  "devDependencies": {
165
164
  "@playwright/test": "^1.29.2",
@@ -184,6 +183,7 @@
184
183
  "@types/send": "^0.17.1",
185
184
  "@types/server-destroy": "^1.0.1",
186
185
  "@types/unist": "^2.0.6",
186
+ "@astrojs/check": "^0.1.0",
187
187
  "chai": "^4.3.7",
188
188
  "cheerio": "1.0.0-rc.12",
189
189
  "eol": "^0.9.1",
@@ -196,22 +196,13 @@
196
196
  "remark-code-titles": "^0.1.2",
197
197
  "rollup": "^3.25.1",
198
198
  "sass": "^1.63.4",
199
- "sharp": "^0.32.1",
200
199
  "srcset-parse": "^1.1.0",
201
200
  "undici": "^5.22.1",
202
201
  "unified": "^10.1.2",
203
202
  "astro-scripts": "0.0.14"
204
203
  },
205
- "peerDependencies": {
206
- "sharp": ">=0.31.0"
207
- },
208
- "peerDependenciesMeta": {
209
- "sharp": {
210
- "optional": true
211
- }
212
- },
213
204
  "engines": {
214
- "node": ">=16.12.0",
205
+ "node": ">=18.14.1",
215
206
  "npm": ">=6.14.0"
216
207
  },
217
208
  "scripts": {
@@ -5,14 +5,19 @@
5
5
  "target": "ESNext",
6
6
  "module": "ESNext",
7
7
  // Enable node-style module resolution, for things like npm package imports.
8
- "moduleResolution": "node",
8
+ "moduleResolution": "Bundler",
9
+ // Allow importing TypeScript files using their native extension (.ts(x)).
10
+ "allowImportingTsExtensions": true,
9
11
  // Enable JSON imports.
10
12
  "resolveJsonModule": true,
11
- // Enable stricter transpilation for better output.
13
+ // Enforce the usage of type-only imports when needed, which helps avoiding bundling issues.
14
+ "verbatimModuleSyntax": true,
15
+ // Ensure that each file can be transpiled without relying on other imports.
16
+ // This is redundant with the previous option, however it ensures that it's on even if someone disable `verbatimModuleSyntax`
12
17
  "isolatedModules": true,
13
18
  // Astro directly run TypeScript code, no transpilation needed.
14
19
  "noEmit": true,
15
- // Report an error when importing a file using a casing different from the casing on disk.
20
+ // Report an error when importing a file using a casing different from another import of the same file.
16
21
  "forceConsistentCasingInFileNames": true,
17
22
  // Properly support importing CJS modules in ESM
18
23
  "esModuleInterop": true,
@@ -23,9 +28,6 @@
23
28
  "paths": {
24
29
  "~/assets/*": ["src/assets/*"]
25
30
  },
26
- // TypeScript 5.0 changed how `isolatedModules` and `importsNotUsedAsValues` works, deprecating the later
27
- // Until the majority of users are on TypeScript 5.0, we'll have to supress those deprecation errors
28
- "ignoreDeprecations": "5.0",
29
31
  // Allow JavaScript files to be imported
30
32
  "allowJs": true
31
33
  }
@@ -2,8 +2,7 @@
2
2
  "$schema": "https://json.schemastore.org/tsconfig",
3
3
  "extends": "./base.json",
4
4
  "compilerOptions": {
5
- "strict": true,
6
- // Error when a value import is only used as a type.
7
- "importsNotUsedAsValues": "error"
5
+ // Enable strict mode. This enables a few options at a time, see https://www.typescriptlang.org/tsconfig#strict for a list.
6
+ "strict": true
8
7
  }
9
8
  }
@@ -1,2 +0,0 @@
1
- import { type Diagnostic } from '@astrojs/language-server';
2
- export declare function printDiagnostic(filePath: string, text: string, diag: Diagnostic): string;
@@ -1,95 +0,0 @@
1
- import { DiagnosticSeverity, offsetAt } from "@astrojs/language-server";
2
- import {
3
- bgRed,
4
- bgWhite,
5
- bgYellow,
6
- black,
7
- bold,
8
- cyan,
9
- gray,
10
- red,
11
- white,
12
- yellow
13
- } from "kleur/colors";
14
- import { fileURLToPath } from "node:url";
15
- import stringWidth from "string-width";
16
- function printDiagnostic(filePath, text, diag) {
17
- let result = [];
18
- const realStartLine = diag.range.start.line + 1;
19
- const realStartCharacter = diag.range.start.character + 1;
20
- const IDEFilePath = `${bold(cyan(fileURLToPath(filePath)))}:${bold(yellow(realStartLine))}:${bold(
21
- yellow(realStartCharacter)
22
- )}`;
23
- result.push(
24
- `${IDEFilePath} ${bold(getColorForSeverity(diag, getStringForSeverity(diag)))}: ${diag.message}`
25
- );
26
- const previousLine = getLine(diag.range.start.line - 1, text);
27
- if (previousLine) {
28
- result.push(`${getPrintableLineNumber(realStartLine - 1)} ${gray(previousLine)}`);
29
- }
30
- const str = getLine(diag.range.start.line, text);
31
- const lineNumStr = realStartLine.toString().padStart(2, "0");
32
- const lineNumLen = lineNumStr.length;
33
- result.push(`${getBackgroundForSeverity(diag, lineNumStr)} ${str}`);
34
- const tildes = generateString("~", diag.range.end.character - diag.range.start.character);
35
- const beforeChars = stringWidth(str.substring(0, diag.range.start.character));
36
- const spaces = generateString(" ", beforeChars + lineNumLen - 1);
37
- result.push(` ${spaces}${bold(getColorForSeverity(diag, tildes))}`);
38
- const nextLine = getLine(diag.range.start.line + 1, text);
39
- if (nextLine) {
40
- result.push(`${getPrintableLineNumber(realStartLine + 1)} ${gray(nextLine)}`);
41
- }
42
- result.push("");
43
- return result.join("\n");
44
- }
45
- function generateString(str, len) {
46
- return Array.from({ length: len }, () => str).join("");
47
- }
48
- function getStringForSeverity(diag) {
49
- switch (diag.severity) {
50
- case DiagnosticSeverity.Error:
51
- return "Error";
52
- case DiagnosticSeverity.Warning:
53
- return "Warning";
54
- case DiagnosticSeverity.Hint:
55
- return "Hint";
56
- default:
57
- return "Unknown";
58
- }
59
- }
60
- function getColorForSeverity(diag, text) {
61
- switch (diag.severity) {
62
- case DiagnosticSeverity.Error:
63
- return red(text);
64
- case DiagnosticSeverity.Warning:
65
- return yellow(text);
66
- case DiagnosticSeverity.Hint:
67
- return gray(text);
68
- default:
69
- return text;
70
- }
71
- }
72
- function getBackgroundForSeverity(diag, text) {
73
- switch (diag.severity) {
74
- case DiagnosticSeverity.Error:
75
- return bgRed(white(text));
76
- case DiagnosticSeverity.Warning:
77
- return bgYellow(white(text));
78
- case DiagnosticSeverity.Hint:
79
- return bgWhite(black(text));
80
- default:
81
- return text;
82
- }
83
- }
84
- function getPrintableLineNumber(line) {
85
- return bgWhite(black(line.toString().padStart(2, "0")));
86
- }
87
- function getLine(line, text) {
88
- return text.substring(
89
- offsetAt({ line, character: 0 }, text),
90
- offsetAt({ line, character: Number.MAX_SAFE_INTEGER }, text)
91
- ).replace(/\t/g, " ").trimEnd();
92
- }
93
- export {
94
- printDiagnostic
95
- };