astro 4.0.1 → 4.0.3

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.
package/astro-jsx.d.ts CHANGED
@@ -36,6 +36,7 @@ declare namespace astroHTML.JSX {
36
36
  AstroDefineVarsAttribute;
37
37
  type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes &
38
38
  AstroDefineVarsAttribute;
39
+ type AstroSlotAttributes = import('./dist/@types/astro.js').AstroSlotAttributes;
39
40
 
40
41
  // This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
41
42
  // without importing every single framework's types (which comes with its own set of problems).
@@ -1415,7 +1416,7 @@ declare namespace astroHTML.JSX {
1415
1416
  ruby: HTMLAttributes;
1416
1417
  s: HTMLAttributes;
1417
1418
  samp: HTMLAttributes;
1418
- slot: SlotHTMLAttributes;
1419
+ slot: SlotHTMLAttributes & AstroSlotAttributes;
1419
1420
  script: ScriptHTMLAttributes & AstroScriptAttributes;
1420
1421
  section: HTMLAttributes;
1421
1422
  select: SelectHTMLAttributes;
@@ -104,6 +104,12 @@ const { fallback = 'animate' } = Astro.props;
104
104
  let action = submitter?.getAttribute('formaction') ?? form.action ?? location.pathname;
105
105
  const method = submitter?.getAttribute('formmethod') ?? form.method;
106
106
 
107
+ // the "dialog" method is a special keyword used within <dialog> elements
108
+ // https://html.spec.whatwg.org/multipage/form-control-infrastructure.html#attr-fs-method
109
+ if (method === 'dialog') {
110
+ return;
111
+ }
112
+
107
113
  const options: Options = { sourceElement: submitter ?? form };
108
114
  if (method === 'get') {
109
115
  const params = new URLSearchParams(formData as any);
@@ -113,6 +119,7 @@ const { fallback = 'animate' } = Astro.props;
113
119
  } else {
114
120
  options.formData = formData;
115
121
  }
122
+
116
123
  ev.preventDefault();
117
124
  navigate(action, options);
118
125
  });
@@ -73,6 +73,9 @@ export interface AstroStyleAttributes {
73
73
  export interface AstroScriptAttributes {
74
74
  'is:inline'?: boolean;
75
75
  }
76
+ export interface AstroSlotAttributes {
77
+ 'is:inline'?: boolean;
78
+ }
76
79
  export interface AstroComponentMetadata {
77
80
  displayName: string;
78
81
  hydrate?: 'load' | 'idle' | 'visible' | 'media' | 'only';
@@ -1250,37 +1253,19 @@ export interface AstroUserConfig {
1250
1253
  /**
1251
1254
  * @docs
1252
1255
  * @kind heading
1253
- * @name Legacy Flags
1254
- * @description
1255
- * To help some users migrate between versions of Astro, we occasionally introduce `legacy` flags.
1256
- * These flags allow you to opt in to some deprecated or otherwise outdated behavior of Astro
1257
- * in the latest version, so that you can continue to upgrade and take advantage of new Astro releases.
1258
- */
1259
- legacy?: object;
1260
- /**
1261
- * @docs
1262
- * @kind heading
1263
- * @name Experimental Flags
1264
- * @description
1265
- * Astro offers experimental flags to give users early access to new features.
1266
- * These flags are not guaranteed to be stable.
1267
- */
1268
- /**
1269
- * @docs
1270
1256
  * @name i18n
1271
1257
  * @type {object}
1272
1258
  * @version 3.5.0
1273
1259
  * @type {object}
1274
1260
  * @description
1275
1261
  *
1276
- * Configures experimental i18n routing and allows you to specify some customization options.
1262
+ * Configures i18n routing and allows you to specify some customization options.
1277
1263
  *
1278
1264
  * See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
1279
1265
  */
1280
1266
  i18n?: {
1281
1267
  /**
1282
1268
  * @docs
1283
- * @kind h4
1284
1269
  * @name i18n.defaultLocale
1285
1270
  * @type {string}
1286
1271
  * @version 3.5.0
@@ -1293,7 +1278,6 @@ export interface AstroUserConfig {
1293
1278
  defaultLocale: string;
1294
1279
  /**
1295
1280
  * @docs
1296
- * @kind h4
1297
1281
  * @name i18n.locales
1298
1282
  * @type {Locales}
1299
1283
  * @version 3.5.0
@@ -1308,7 +1292,6 @@ export interface AstroUserConfig {
1308
1292
  locales: Locales;
1309
1293
  /**
1310
1294
  * @docs
1311
- * @kind h4
1312
1295
  * @name i18n.fallback
1313
1296
  * @type {Record<string, string>}
1314
1297
  * @version 3.5.0
@@ -1324,14 +1307,12 @@ export interface AstroUserConfig {
1324
1307
  *
1325
1308
  * ```js
1326
1309
  * export default defineConfig({
1327
- * experimental: {
1328
- * i18n: {
1329
- * defaultLocale: "en",
1330
- * locales: ["en", "fr", "pt-br", "es"],
1331
- * fallback: {
1332
- * pt: "es",
1333
- * fr: "en"
1334
- * }
1310
+ * i18n: {
1311
+ * defaultLocale: "en",
1312
+ * locales: ["en", "fr", "pt-br", "es"],
1313
+ * fallback: {
1314
+ * pt: "es",
1315
+ * fr: "en"
1335
1316
  * }
1336
1317
  * }
1337
1318
  * })
@@ -1340,7 +1321,6 @@ export interface AstroUserConfig {
1340
1321
  fallback?: Record<string, string>;
1341
1322
  /**
1342
1323
  * @docs
1343
- * @kind h4
1344
1324
  * @name i18n.routing
1345
1325
  * @type {Routing}
1346
1326
  * @version 3.7.0
@@ -1352,6 +1332,7 @@ export interface AstroUserConfig {
1352
1332
  /**
1353
1333
  * @docs
1354
1334
  * @name i18n.routing.prefixDefaultLocale
1335
+ * @kind h4
1355
1336
  * @type {boolean}
1356
1337
  * @default `false`
1357
1338
  * @version 3.7.0
@@ -1378,6 +1359,24 @@ export interface AstroUserConfig {
1378
1359
  strategy: 'pathname';
1379
1360
  };
1380
1361
  };
1362
+ /**
1363
+ * @docs
1364
+ * @kind heading
1365
+ * @name Legacy Flags
1366
+ * @description
1367
+ * To help some users migrate between versions of Astro, we occasionally introduce `legacy` flags.
1368
+ * These flags allow you to opt in to some deprecated or otherwise outdated behavior of Astro
1369
+ * in the latest version, so that you can continue to upgrade and take advantage of new Astro releases.
1370
+ */
1371
+ legacy?: object;
1372
+ /**
1373
+ * @docs
1374
+ * @kind heading
1375
+ * @name Experimental Flags
1376
+ * @description
1377
+ * Astro offers experimental flags to give users early access to new features.
1378
+ * These flags are not guaranteed to be stable.
1379
+ */
1381
1380
  experimental?: {
1382
1381
  /**
1383
1382
  * @docs
@@ -1969,7 +1968,7 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
1969
1968
  */
1970
1969
  locals: App.Locals;
1971
1970
  /**
1972
- * Available only when `experimental.i18n` enabled and in SSR.
1971
+ * Available only when `i18n` configured and in SSR.
1973
1972
  *
1974
1973
  * It represents the preferred locale of the user. It's computed by checking the supported locales in `i18n.locales`
1975
1974
  * and locales supported by the users's browser via the header `Accept-Language`
@@ -1981,7 +1980,7 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
1981
1980
  */
1982
1981
  preferredLocale: string | undefined;
1983
1982
  /**
1984
- * Available only when `experimental.i18n` enabled and in SSR.
1983
+ * Available only when `i18n` configured and in SSR.
1985
1984
  *
1986
1985
  * It represents the list of the preferred locales that are supported by the application. The list is sorted via [quality value].
1987
1986
  *
@@ -1,9 +1,11 @@
1
1
  import type { TransformResult } from '@astrojs/compiler';
2
2
  import type { ResolvedConfig } from 'vite';
3
3
  import type { AstroConfig } from '../../@types/astro.js';
4
+ import type { AstroPreferences } from '../../preferences/index.js';
4
5
  export interface CompileProps {
5
6
  astroConfig: AstroConfig;
6
7
  viteConfig: ResolvedConfig;
8
+ preferences: AstroPreferences;
7
9
  filename: string;
8
10
  source: string;
9
11
  }
@@ -11,4 +13,4 @@ export interface CompileResult extends TransformResult {
11
13
  cssDeps: Set<string>;
12
14
  source: string;
13
15
  }
14
- export declare function compile({ astroConfig, viteConfig, filename, source, }: CompileProps): Promise<CompileResult>;
16
+ export declare function compile({ astroConfig, viteConfig, preferences, filename, source, }: CompileProps): Promise<CompileResult>;
@@ -8,6 +8,7 @@ import { createStylePreprocessor } from "./style.js";
8
8
  async function compile({
9
9
  astroConfig,
10
10
  viteConfig,
11
+ preferences,
11
12
  filename,
12
13
  source
13
14
  }) {
@@ -25,7 +26,7 @@ async function compile({
25
26
  scopedStyleStrategy: astroConfig.scopedStyleStrategy,
26
27
  resultScopedSlot: true,
27
28
  transitionsAnimationURL: "astro/components/viewtransitions.css",
28
- annotateSourceFile: viteConfig.command === "serve" && astroConfig.devToolbar && astroConfig.devToolbar.enabled,
29
+ annotateSourceFile: viteConfig.command === "serve" && astroConfig.devToolbar && astroConfig.devToolbar.enabled && await preferences.get("devToolbar.enabled"),
29
30
  preprocessStyle: createStylePreprocessor({
30
31
  filename,
31
32
  viteConfig,
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.0.1";
1
+ const ASTRO_VERSION = "4.0.3";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -21,7 +21,7 @@ async function dev(inlineConfig) {
21
21
  base: restart.container.settings.config.base
22
22
  })
23
23
  );
24
- const currentVersion = "4.0.1";
24
+ const currentVersion = "4.0.3";
25
25
  if (currentVersion.includes("-")) {
26
26
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
27
27
  }
@@ -27,7 +27,7 @@ function req({
27
27
  statusCode,
28
28
  reqTime
29
29
  }) {
30
- const color = statusCode >= 400 ? red : statusCode >= 300 ? yellow : blue;
30
+ const color = statusCode >= 500 ? red : statusCode >= 300 ? yellow : blue;
31
31
  return color(`[${statusCode}]`) + ` ` + (method && method !== "GET" ? color(method) + " " : "") + url + ` ` + (reqTime ? dim(Math.round(reqTime) + "ms") : "");
32
32
  }
33
33
  function serverStart({
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.0.1";
39
+ const version = "4.0.3";
40
40
  const localPrefix = `${dim("\u2503")} Local `;
41
41
  const networkPrefix = `${dim("\u2503")} Network `;
42
42
  const emptyPrefix = " ".repeat(11);
@@ -258,7 +258,7 @@ function printHelp({
258
258
  message.push(
259
259
  linebreak(),
260
260
  ` ${bgGreen(black(` ${commandName} `))} ${green(
261
- `v${"4.0.1"}`
261
+ `v${"4.0.3"}`
262
262
  )} ${headline}`
263
263
  );
264
264
  }
@@ -13,7 +13,7 @@ const settingsRows = [
13
13
  devOverlay.setNotificationVisible(!evt.currentTarget.checked);
14
14
  }
15
15
  settings.updateSetting("disablePluginNotification", evt.currentTarget.checked);
16
- const action = evt.currentTarget.checked ? "enabled" : "disabled";
16
+ const action = evt.currentTarget.checked ? "disabled" : "enabled";
17
17
  settings.log(`Plugin notification badges ${action}`);
18
18
  }
19
19
  }
@@ -113,6 +113,7 @@ File: ${id}`
113
113
  const compileProps = {
114
114
  astroConfig: config,
115
115
  viteConfig: resolvedConfig,
116
+ preferences: settings.preferences,
116
117
  filename: normalizePath(parsedId.filename),
117
118
  source
118
119
  };
@@ -149,6 +150,7 @@ File: ${id}`
149
150
  const compile = () => cachedCompilation({
150
151
  astroConfig: config,
151
152
  viteConfig: resolvedConfig,
153
+ preferences: settings.preferences,
152
154
  filename,
153
155
  source
154
156
  });
@@ -253,7 +253,7 @@ async function handleRoute({
253
253
  req({
254
254
  url: pathname,
255
255
  method: incomingRequest.method,
256
- statusCode: response.status,
256
+ statusCode: status ?? response.status,
257
257
  reqTime: timeEnd - timeStart
258
258
  })
259
259
  );
@@ -277,22 +277,16 @@ async function handleRoute({
277
277
  }
278
278
  if (route.type === "endpoint") {
279
279
  await writeWebResponse(incomingResponse, response);
280
- } else {
281
- if (
282
- // We are in a recursion, and it's possible that this function is called itself with a status code
283
- // By default, the status code passed via parameters is computed by the matched route.
284
- //
285
- // By default, we should give priority to the status code passed, although it's possible that
286
- // the `Response` emitted by the user is a redirect. If so, then return the returned response.
287
- response.status < 400 && response.status >= 300
288
- ) {
289
- await writeSSRResult(request, response, incomingResponse);
290
- return;
291
- } else if (status && response.status !== status && (status === 404 || status === 500)) {
292
- response = new Response(response.body, { ...response, status });
293
- }
280
+ return;
281
+ }
282
+ if (response.status < 400 && response.status >= 300) {
294
283
  await writeSSRResult(request, response, incomingResponse);
284
+ return;
285
+ }
286
+ if (status && response.status !== status && (status === 404 || status === 500)) {
287
+ response = new Response(response.body, { ...response, status });
295
288
  }
289
+ await writeSSRResult(request, response, incomingResponse);
296
290
  }
297
291
  async function getScriptsAndStyles({ pipeline, filePath }) {
298
292
  const moduleLoader = pipeline.getModuleLoader();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.0.1",
3
+ "version": "4.0.3",
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",
@@ -153,13 +153,13 @@
153
153
  "unist-util-visit": "^5.0.0",
154
154
  "vfile": "^6.0.1",
155
155
  "vite": "^5.0.0",
156
- "vitefu": "^0.2.4",
156
+ "vitefu": "^0.2.5",
157
157
  "which-pm": "^2.1.1",
158
158
  "yargs-parser": "^21.1.1",
159
159
  "zod": "^3.22.4",
160
- "@astrojs/internal-helpers": "0.2.1",
161
160
  "@astrojs/markdown-remark": "4.0.0",
162
- "@astrojs/telemetry": "3.0.4"
161
+ "@astrojs/telemetry": "3.0.4",
162
+ "@astrojs/internal-helpers": "0.2.1"
163
163
  },
164
164
  "optionalDependencies": {
165
165
  "sharp": "^0.32.5"