astro 4.0.0-beta.4 → 4.0.0-beta.5

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 (51) hide show
  1. package/LICENSE +0 -2
  2. package/dist/@types/astro.d.ts +112 -111
  3. package/dist/assets/build/generate.d.ts +1 -1
  4. package/dist/assets/build/generate.js +0 -1
  5. package/dist/core/build/buildPipeline.d.ts +1 -1
  6. package/dist/core/build/buildPipeline.js +0 -1
  7. package/dist/core/build/generate.js +7 -7
  8. package/dist/core/build/index.js +1 -1
  9. package/dist/core/build/plugins/plugin-manifest.js +5 -5
  10. package/dist/core/build/util.js +2 -2
  11. package/dist/core/compile/compile.js +1 -1
  12. package/dist/core/config/schema.d.ts +214 -256
  13. package/dist/core/config/schema.js +66 -66
  14. package/dist/core/constants.js +1 -1
  15. package/dist/core/create-vite.js +1 -1
  16. package/dist/core/dev/dev.js +1 -1
  17. package/dist/core/dev/restart.d.ts +1 -1
  18. package/dist/core/dev/restart.js +0 -1
  19. package/dist/core/logger/node.js +0 -1
  20. package/dist/core/messages.js +2 -2
  21. package/dist/core/render/params-and-props.d.ts +1 -1
  22. package/dist/core/render/params-and-props.js +1 -1
  23. package/dist/core/render/route-cache.js +0 -1
  24. package/dist/core/routing/manifest/create.js +1 -2
  25. package/dist/i18n/index.d.ts +4 -4
  26. package/dist/i18n/index.js +4 -4
  27. package/dist/i18n/vite-plugin-i18n.js +1 -1
  28. package/dist/integrations/index.d.ts +1 -1
  29. package/dist/integrations/index.js +0 -1
  30. package/dist/runtime/client/dev-overlay/entrypoint.js +4 -6
  31. package/dist/runtime/client/dev-overlay/overlay.js +6 -27
  32. package/dist/runtime/client/dev-overlay/plugins/audit/a11y.d.ts +26 -0
  33. package/dist/runtime/client/dev-overlay/plugins/audit/a11y.js +580 -0
  34. package/dist/runtime/client/dev-overlay/plugins/{audit.d.ts → audit/index.d.ts} +15 -0
  35. package/dist/runtime/client/dev-overlay/plugins/{audit.js → audit/index.js} +67 -15
  36. package/dist/runtime/client/dev-overlay/plugins/settings.js +16 -9
  37. package/dist/runtime/client/dev-overlay/plugins/utils/highlight.js +3 -0
  38. package/dist/runtime/client/dev-overlay/plugins/xray.d.ts +1 -1
  39. package/dist/runtime/client/dev-overlay/plugins/xray.js +37 -7
  40. package/dist/runtime/client/dev-overlay/ui-library/tooltip.js +8 -3
  41. package/dist/runtime/client/dev-overlay/ui-library/window.js +4 -0
  42. package/dist/runtime/server/render/common.d.ts +1 -1
  43. package/dist/runtime/server/render/common.js +1 -1
  44. package/dist/runtime/server/render/component.d.ts +1 -1
  45. package/dist/runtime/server/render/component.js +1 -1
  46. package/dist/transitions/router.js +33 -46
  47. package/dist/vite-plugin-astro/hmr.d.ts +1 -1
  48. package/dist/vite-plugin-astro/hmr.js +1 -5
  49. package/dist/vite-plugin-astro-server/plugin.js +5 -5
  50. package/dist/vite-plugin-astro-server/route.js +6 -10
  51. package/package.json +4 -1
package/LICENSE CHANGED
@@ -20,7 +20,6 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
20
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
21
  SOFTWARE.
22
22
 
23
-
24
23
  """
25
24
  This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/sveltejs/kit repository:
26
25
 
@@ -33,7 +32,6 @@ The above copyright notice and this permission notice shall be included in all c
33
32
  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
33
  """
35
34
 
36
-
37
35
  """
38
36
  This license applies to parts of the `packages/create-astro` and `packages/astro` subdirectories originating from the https://github.com/vitejs/vite repository:
39
37
 
@@ -1302,141 +1302,141 @@ export interface AstroUserConfig {
1302
1302
  * Astro offers experimental flags to give users early access to new features.
1303
1303
  * These flags are not guaranteed to be stable.
1304
1304
  */
1305
- experimental?: {
1305
+ /**
1306
+ * @docs
1307
+ * @name i18n
1308
+ * @type {object}
1309
+ * @version 3.5.0
1310
+ * @type {object}
1311
+ * @description
1312
+ *
1313
+ * Configures experimental i18n routing and allows you to specify some customization options.
1314
+ *
1315
+ * See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
1316
+ */
1317
+ i18n?: {
1306
1318
  /**
1307
1319
  * @docs
1308
- * @name experimental.optimizeHoistedScript
1309
- * @type {boolean}
1310
- * @default `false`
1311
- * @version 2.10.4
1320
+ * @kind h4
1321
+ * @name i18n.defaultLocale
1322
+ * @type {string}
1323
+ * @version 3.5.0
1324
+ * @description
1325
+ *
1326
+ * The default locale of your website/application. This is a required field.
1327
+ *
1328
+ * No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility.
1329
+ */
1330
+ defaultLocale: string;
1331
+ /**
1332
+ * @docs
1333
+ * @kind h4
1334
+ * @name i18n.locales
1335
+ * @type {Locales}
1336
+ * @version 3.5.0
1337
+ * @description
1338
+ *
1339
+ * A list of all locales supported by the website, including the `defaultLocale`. This is a required field.
1340
+ *
1341
+ * Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site.
1342
+ *
1343
+ * No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured.
1344
+ */
1345
+ locales: Locales;
1346
+ /**
1347
+ * @docs
1348
+ * @kind h4
1349
+ * @name i18n.fallback
1350
+ * @type {Record<string, string>}
1351
+ * @version 3.5.0
1312
1352
  * @description
1313
- * Prevents unused components' scripts from being included in a page unexpectedly.
1314
- * The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages
1315
- * before publishing.
1316
- * Enable hoisted script analysis optimization by adding the experimental flag:
1353
+ *
1354
+ * The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created).
1355
+ *
1356
+ * Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404.
1357
+ *
1358
+ * ##### Example
1359
+ *
1360
+ * The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
1317
1361
  *
1318
1362
  * ```js
1319
- * {
1363
+ * export default defineConfig({
1320
1364
  * experimental: {
1321
- * optimizeHoistedScript: true,
1322
- * },
1323
- * }
1365
+ * i18n: {
1366
+ * defaultLocale: "en",
1367
+ * locales: ["en", "fr", "pt-br", "es"],
1368
+ * fallback: {
1369
+ * pt: "es",
1370
+ * fr: "en"
1371
+ * }
1372
+ * }
1373
+ * }
1374
+ * })
1324
1375
  * ```
1325
1376
  */
1326
- optimizeHoistedScript?: boolean;
1377
+ fallback?: Record<string, string>;
1327
1378
  /**
1328
1379
  * @docs
1329
- * @name experimental.i18n
1330
- * @type {object}
1331
- * @version 3.5.0
1332
- * @type {object}
1380
+ * @kind h4
1381
+ * @name i18n.routing
1382
+ * @type {Routing}
1383
+ * @version 3.7.0
1333
1384
  * @description
1334
1385
  *
1335
- * Configures experimental i18n routing and allows you to specify some customization options.
1336
- *
1337
- * See our guide for more information on [internationalization in Astro](/en/guides/internationalization/)
1386
+ * Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
1338
1387
  */
1339
- i18n?: {
1388
+ routing?: {
1340
1389
  /**
1341
1390
  * @docs
1342
- * @kind h4
1343
- * @name experimental.i18n.defaultLocale
1344
- * @type {string}
1345
- * @version 3.5.0
1346
- * @description
1347
- *
1348
- * The default locale of your website/application. This is a required field.
1349
- *
1350
- * No particular language format or syntax is enforced, but we suggest using lower-case and hyphens as needed (e.g. "es", "pt-br") for greatest compatibility.
1351
- */
1352
- defaultLocale: string;
1353
- /**
1354
- * @docs
1355
- * @kind h4
1356
- * @name experimental.i18n.locales
1357
- * @type {Locales}
1358
- * @version 3.5.0
1359
- * @description
1360
- *
1361
- * A list of all locales supported by the website, including the `defaultLocale`. This is a required field.
1362
- *
1363
- * Languages can be listed either as individual codes (e.g. `['en', 'es', 'pt-br']`) or mapped to a shared `path` of codes (e.g. `{ path: "english", codes: ["en", "en-US"]}`). These codes will be used to determine the URL structure of your deployed site.
1364
- *
1365
- * No particular language code format or syntax is enforced, but your project folders containing your content files must match exactly the `locales` items in the list. In the case of multiple `codes` pointing to a custom URL path prefix, store your content files in a folder with the same name as the `path` configured.
1366
- */
1367
- locales: Locales;
1368
- /**
1369
- * @docs
1370
- * @kind h4
1371
- * @name experimental.i18n.fallback
1372
- * @type {Record<string, string>}
1373
- * @version 3.5.0
1391
+ * @name i18n.routing.prefixDefaultLocale
1392
+ * @type {boolean}
1393
+ * @default `false`
1394
+ * @version 3.7.0
1374
1395
  * @description
1375
1396
  *
1376
- * The fallback strategy when navigating to pages that do not exist (e.g. a translated page has not been created).
1377
- *
1378
- * Use this object to declare a fallback `locale` route for each language you support. If no fallback is specified, then unavailable pages will return a 404.
1397
+ * When `false`, only non-default languages will display a language prefix.
1398
+ * The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder.
1399
+ * URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale.
1379
1400
  *
1380
- * ##### Example
1381
- *
1382
- * The following example configures your content fallback strategy to redirect unavailable pages in `/pt-br/` to their `es` version, and unavailable pages in `/fr/` to their `en` version. Unavailable `/es/` pages will return a 404.
1383
- *
1384
- * ```js
1385
- * export default defineConfig({
1386
- * experimental: {
1387
- * i18n: {
1388
- * defaultLocale: "en",
1389
- * locales: ["en", "fr", "pt-br", "es"],
1390
- * fallback: {
1391
- * pt: "es",
1392
- * fr: "en"
1393
- * }
1394
- * }
1395
- * }
1396
- * })
1397
- * ```
1401
+ * When `true`, all URLs will display a language prefix.
1402
+ * URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
1403
+ * Localized folders are used for every language, including the default.
1398
1404
  */
1399
- fallback?: Record<string, string>;
1405
+ prefixDefaultLocale: boolean;
1400
1406
  /**
1401
- * @docs
1402
- * @kind h4
1403
- * @name experimental.i18n.routing
1404
- * @type {Routing}
1407
+ * @name i18n.routing.strategy
1408
+ * @type {"pathname"}
1409
+ * @default `"pathname"`
1405
1410
  * @version 3.7.0
1406
1411
  * @description
1407
1412
  *
1408
- * Controls the routing strategy to determine your site URLs. Set this based on your folder/URL path configuration for your default language.
1413
+ * - `"pathanme": The strategy is applied to the pathname of the URLs
1409
1414
  */
1410
- routing?: {
1411
- /**
1412
- * @docs
1413
- * @name experimental.i18n.routing.prefixDefaultLocale
1414
- * @type {boolean}
1415
- * @default `false`
1416
- * @version 3.7.0
1417
- * @description
1418
- *
1419
- * When `false`, only non-default languages will display a language prefix.
1420
- * The `defaultLocale` will not show a language prefix and content files do not exist in a localized folder.
1421
- * URLs will be of the form `example.com/[locale]/content/` for all non-default languages, but `example.com/content/` for the default locale.
1422
- *
1423
- * When `true`, all URLs will display a language prefix.
1424
- * URLs will be of the form `example.com/[locale]/content/` for every route, including the default language.
1425
- * Localized folders are used for every language, including the default.
1426
- */
1427
- prefixDefaultLocale: boolean;
1428
- /**
1429
- * @name experimental.i18n.routing.strategy
1430
- * @type {"pathname"}
1431
- * @default `"pathname"`
1432
- * @version 3.7.0
1433
- * @description
1434
- *
1435
- * - `"pathanme": The strategy is applied to the pathname of the URLs
1436
- */
1437
- strategy: 'pathname';
1438
- };
1415
+ strategy: 'pathname';
1439
1416
  };
1417
+ };
1418
+ experimental?: {
1419
+ /**
1420
+ * @docs
1421
+ * @name experimental.optimizeHoistedScript
1422
+ * @type {boolean}
1423
+ * @default `false`
1424
+ * @version 2.10.4
1425
+ * @description
1426
+ * Prevents unused components' scripts from being included in a page unexpectedly.
1427
+ * The optimization is best-effort and may inversely miss including the used scripts. Make sure to double-check your built pages
1428
+ * before publishing.
1429
+ * Enable hoisted script analysis optimization by adding the experimental flag:
1430
+ *
1431
+ * ```js
1432
+ * {
1433
+ * experimental: {
1434
+ * optimizeHoistedScript: true,
1435
+ * },
1436
+ * }
1437
+ * ```
1438
+ */
1439
+ optimizeHoistedScript?: boolean;
1440
1440
  /**
1441
1441
  * @docs
1442
1442
  * @name experimental.contentCollectionCache
@@ -2287,13 +2287,14 @@ export interface ClientDirectiveConfig {
2287
2287
  name: string;
2288
2288
  entrypoint: string;
2289
2289
  }
2290
- export interface DevOverlayPlugin {
2290
+ export interface DevToolbarApp {
2291
2291
  id: string;
2292
2292
  name: string;
2293
2293
  icon: Icon;
2294
2294
  init?(canvas: ShadowRoot, eventTarget: EventTarget): void | Promise<void>;
2295
2295
  beforeTogglingOff?(canvas: ShadowRoot): boolean | Promise<boolean>;
2296
2296
  }
2297
+ export type DevOverlayPlugin = DevToolbarApp;
2297
2298
  export type DevOverlayMetadata = Window & typeof globalThis & {
2298
2299
  __astro_dev_overlay__: {
2299
2300
  defaultState: AstroConfig['devOverlay']['defaultState'];
@@ -1,4 +1,4 @@
1
- import PQueue from 'p-queue';
1
+ import type PQueue from 'p-queue';
2
2
  import type { AstroConfig } from '../../@types/astro.js';
3
3
  import type { BuildPipeline } from '../../core/build/buildPipeline.js';
4
4
  import type { Logger } from '../../core/logger/core.js';
@@ -1,7 +1,6 @@
1
1
  import { dim, green } from "kleur/colors";
2
2
  import fs, { readFileSync } from "node:fs";
3
3
  import { basename, join } from "node:path/posix";
4
- import PQueue from "p-queue";
5
4
  import { getOutDirWithinCwd } from "../../core/build/common.js";
6
5
  import { getTimeStat } from "../../core/build/util.js";
7
6
  import { isRemotePath, prependForwardSlash } from "../../core/path.js";
@@ -1,6 +1,6 @@
1
1
  import type { AstroConfig, AstroSettings } from '../../@types/astro.js';
2
2
  import type { SSRManifest } from '../app/types.js';
3
- import { Logger } from '../logger/core.js';
3
+ import type { Logger } from '../logger/core.js';
4
4
  import { Pipeline } from '../pipeline.js';
5
5
  import type { BuildInternals } from './internal.js';
6
6
  import type { PageBuildData, StaticBuildOptions } from './types.js';
@@ -1,6 +1,5 @@
1
1
  import { getOutputDirectory, isServerLikeOutput } from "../../prerender/utils.js";
2
2
  import { BEFORE_HYDRATION_SCRIPT_ID } from "../../vite-plugin-scripts/index.js";
3
- import { Logger } from "../logger/core.js";
4
3
  import { Pipeline } from "../pipeline.js";
5
4
  import { routeIsFallback, routeIsRedirect } from "../redirects/helpers.js";
6
5
  import { createEnvironment } from "../render/index.js";
@@ -200,7 +200,7 @@ async function generatePage(pageData, ssrEntry, builtPaths, pipeline) {
200
200
  pipeline.getManifest().base,
201
201
  pipeline.getManifest().trailingSlash
202
202
  );
203
- if (config.experimental.i18n && i18nMiddleware) {
203
+ if (config.i18n && i18nMiddleware) {
204
204
  if (onRequest) {
205
205
  pipeline.setMiddlewareFunction(sequence(i18nMiddleware, onRequest));
206
206
  } else {
@@ -396,7 +396,7 @@ async function generatePath(pathname, pipeline, gopts, route) {
396
396
  logger: pipeline.getLogger(),
397
397
  ssr
398
398
  });
399
- const i18n = pipeline.getConfig().experimental.i18n;
399
+ const i18n = pipeline.getConfig().i18n;
400
400
  const renderContext = await createRenderContext({
401
401
  pathname,
402
402
  request,
@@ -457,12 +457,12 @@ async function generatePath(pathname, pipeline, gopts, route) {
457
457
  }
458
458
  function createBuildManifest(settings, internals, renderers) {
459
459
  let i18nManifest = void 0;
460
- if (settings.config.experimental.i18n) {
460
+ if (settings.config.i18n) {
461
461
  i18nManifest = {
462
- fallback: settings.config.experimental.i18n.fallback,
463
- routing: settings.config.experimental.i18n.routing,
464
- defaultLocale: settings.config.experimental.i18n.defaultLocale,
465
- locales: settings.config.experimental.i18n.locales
462
+ fallback: settings.config.i18n.fallback,
463
+ routing: settings.config.i18n.routing,
464
+ defaultLocale: settings.config.i18n.defaultLocale,
465
+ locales: settings.config.i18n.locales
466
466
  };
467
467
  }
468
468
  return {
@@ -16,7 +16,7 @@ import { resolveConfig } from "../config/config.js";
16
16
  import { createNodeLogger } from "../config/logging.js";
17
17
  import { createSettings } from "../config/settings.js";
18
18
  import { createVite } from "../create-vite.js";
19
- import { Logger, levels, timerMessage } from "../logger/core.js";
19
+ import { levels, timerMessage } from "../logger/core.js";
20
20
  import { apply as applyPolyfill } from "../polyfill.js";
21
21
  import { RouteCache } from "../render/route-cache.js";
22
22
  import { createRouteManifest } from "../routing/index.js";
@@ -180,12 +180,12 @@ function buildManifest(opts, internals, staticFiles) {
180
180
  entryModules[BEFORE_HYDRATION_SCRIPT_ID] = "";
181
181
  }
182
182
  let i18nManifest = void 0;
183
- if (settings.config.experimental.i18n) {
183
+ if (settings.config.i18n) {
184
184
  i18nManifest = {
185
- fallback: settings.config.experimental.i18n.fallback,
186
- routing: settings.config.experimental.i18n.routing,
187
- locales: settings.config.experimental.i18n.locales,
188
- defaultLocale: settings.config.experimental.i18n.defaultLocale
185
+ fallback: settings.config.i18n.fallback,
186
+ routing: settings.config.i18n.routing,
187
+ locales: settings.config.i18n.locales,
188
+ defaultLocale: settings.config.i18n.defaultLocale
189
189
  };
190
190
  }
191
191
  return {
@@ -19,8 +19,8 @@ function shouldAppendForwardSlash(trailingSlash, buildFormat) {
19
19
  }
20
20
  }
21
21
  function i18nHasFallback(config) {
22
- if (config.experimental.i18n && config.experimental.i18n.fallback) {
23
- return Object.keys(config.experimental.i18n.fallback).length > 0;
22
+ if (config.i18n && config.i18n.fallback) {
23
+ return Object.keys(config.i18n.fallback).length > 0;
24
24
  }
25
25
  return false;
26
26
  }
@@ -1,7 +1,7 @@
1
1
  import { transform } from "@astrojs/compiler";
2
2
  import { fileURLToPath } from "node:url";
3
3
  import { normalizePath } from "vite";
4
- import { AggregateError, AstroError, CompilerError } from "../errors/errors.js";
4
+ import { AggregateError, CompilerError } from "../errors/errors.js";
5
5
  import { AstroErrorData } from "../errors/index.js";
6
6
  import { resolvePath } from "../util.js";
7
7
  import { createStylePreprocessor } from "./style.js";