astro 2.10.0 → 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 (149) hide show
  1. package/astro.js +2 -2
  2. package/dist/@types/astro.d.ts +67 -7
  3. package/dist/@types/astro.js +1 -0
  4. package/dist/assets/generate.js +7 -3
  5. package/dist/assets/image-endpoint.d.ts +1 -1
  6. package/dist/assets/image-endpoint.js +3 -3
  7. package/dist/assets/internal.js +1 -2
  8. package/dist/assets/services/noop.d.ts +3 -0
  9. package/dist/assets/services/noop.js +17 -0
  10. package/dist/assets/services/vendor/squoosh/image_data.js +3 -0
  11. package/dist/assets/services/vendor/squoosh/impl.js +2 -3
  12. package/dist/assets/services/vendor/squoosh/utils/workerPool.js +4 -0
  13. package/dist/assets/vendor/image-size/types/tiff.js +1 -1
  14. package/dist/assets/vendor/queue/queue.d.ts +3 -3
  15. package/dist/assets/vite-plugin-assets.d.ts +1 -1
  16. package/dist/assets/vite-plugin-assets.js +0 -22
  17. package/dist/cli/add/index.js +6 -9
  18. package/dist/cli/build/index.js +1 -1
  19. package/dist/cli/check/index.d.ts +2 -78
  20. package/dist/cli/check/index.js +23 -275
  21. package/dist/cli/dev/index.js +1 -1
  22. package/dist/cli/index.js +7 -13
  23. package/dist/cli/info/index.js +3 -4
  24. package/dist/cli/install-package.d.ts +7 -0
  25. package/dist/cli/install-package.js +102 -0
  26. package/dist/cli/preview/index.js +1 -1
  27. package/dist/cli/sync/index.js +1 -1
  28. package/dist/content/runtime-assets.js +1 -2
  29. package/dist/content/runtime.js +3 -5
  30. package/dist/content/server-listeners.js +1 -2
  31. package/dist/content/types-generator.js +8 -8
  32. package/dist/content/utils.js +3 -4
  33. package/dist/content/vite-plugin-content-assets.js +4 -6
  34. package/dist/content/vite-plugin-content-imports.js +1 -1
  35. package/dist/content/vite-plugin-content-virtual-mod.js +4 -5
  36. package/dist/core/app/node.d.ts +1 -1
  37. package/dist/core/app/node.js +7 -2
  38. package/dist/core/build/css-asset-name.js +2 -4
  39. package/dist/core/build/generate.js +10 -17
  40. package/dist/core/build/graph.js +3 -4
  41. package/dist/core/build/index.js +8 -1
  42. package/dist/core/build/internal.js +2 -2
  43. package/dist/core/build/plugin.js +2 -4
  44. package/dist/core/build/plugins/plugin-analyzer.js +6 -9
  45. package/dist/core/build/plugins/plugin-component-entry.js +2 -4
  46. package/dist/core/build/plugins/plugin-css.js +6 -9
  47. package/dist/core/build/plugins/plugin-hoisted-scripts.js +2 -3
  48. package/dist/core/build/plugins/plugin-internals.js +1 -2
  49. package/dist/core/build/plugins/plugin-pages.js +5 -1
  50. package/dist/core/build/plugins/plugin-ssr.js +12 -8
  51. package/dist/core/build/static-build.js +8 -12
  52. package/dist/core/client-directive/build.js +1 -2
  53. package/dist/core/compile/compile.js +1 -1
  54. package/dist/core/compile/style.js +2 -3
  55. package/dist/core/config/schema.d.ts +8 -0
  56. package/dist/core/config/schema.js +11 -3
  57. package/dist/core/config/settings.js +3 -3
  58. package/dist/core/config/timer.js +5 -6
  59. package/dist/core/constants.js +1 -1
  60. package/dist/core/cookies/cookies.d.ts +5 -5
  61. package/dist/core/cookies/cookies.js +9 -9
  62. package/dist/core/create-vite.js +6 -28
  63. package/dist/core/dev/dev.js +2 -3
  64. package/dist/core/dev/restart.js +1 -0
  65. package/dist/core/endpoint/dev/index.js +1 -1
  66. package/dist/core/endpoint/index.js +3 -4
  67. package/dist/core/errors/dev/utils.js +12 -16
  68. package/dist/core/errors/dev/vite.js +11 -13
  69. package/dist/core/errors/errors-data.d.ts +21 -0
  70. package/dist/core/errors/errors-data.js +21 -0
  71. package/dist/core/errors/errors.js +12 -17
  72. package/dist/core/errors/overlay.js +7 -8
  73. package/dist/core/errors/utils.js +1 -1
  74. package/dist/core/fs/index.js +1 -1
  75. package/dist/core/logger/console.js +1 -1
  76. package/dist/core/logger/core.d.ts +26 -6
  77. package/dist/core/logger/core.js +54 -8
  78. package/dist/core/logger/node.d.ts +4 -4
  79. package/dist/core/logger/node.js +6 -6
  80. package/dist/core/messages.js +4 -5
  81. package/dist/core/module-loader/vite.js +2 -2
  82. package/dist/core/polyfill.js +12 -4
  83. package/dist/core/redirects/helpers.js +3 -3
  84. package/dist/core/render/core.js +1 -4
  85. package/dist/core/render/params-and-props.js +2 -3
  86. package/dist/core/render/result.js +1 -2
  87. package/dist/core/render/route-cache.d.ts +1 -2
  88. package/dist/core/render/route-cache.js +6 -11
  89. package/dist/core/routing/manifest/create.js +2 -6
  90. package/dist/core/routing/params.js +1 -1
  91. package/dist/core/routing/validation.js +7 -8
  92. package/dist/core/sync/index.js +1 -1
  93. package/dist/core/util.js +1 -1
  94. package/dist/events/error.js +1 -1
  95. package/dist/events/session.js +12 -13
  96. package/dist/integrations/astroFeaturesValidation.d.ts +14 -0
  97. package/dist/integrations/astroFeaturesValidation.js +109 -0
  98. package/dist/integrations/index.d.ts +3 -1
  99. package/dist/integrations/index.js +96 -31
  100. package/dist/jsx/babel.js +1 -2
  101. package/dist/prerender/metadata.js +1 -2
  102. package/dist/runtime/client/hmr.js +1 -2
  103. package/dist/runtime/server/astro-component.js +1 -2
  104. package/dist/runtime/server/astro-island.js +53 -55
  105. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  106. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  107. package/dist/runtime/server/endpoint.d.ts +2 -1
  108. package/dist/runtime/server/endpoint.js +21 -27
  109. package/dist/runtime/server/jsx.js +3 -2
  110. package/dist/runtime/server/render/astro/instance.js +6 -3
  111. package/dist/runtime/server/render/astro/render-template.js +4 -3
  112. package/dist/runtime/server/render/astro/render.js +3 -3
  113. package/dist/runtime/server/render/common.js +1 -1
  114. package/dist/runtime/server/render/component.js +11 -13
  115. package/dist/runtime/server/render/dom.js +1 -1
  116. package/dist/runtime/server/render/page.js +2 -3
  117. package/dist/runtime/server/render/slot.js +2 -1
  118. package/dist/runtime/server/render/util.js +1 -2
  119. package/dist/transitions/vite-plugin-transitions.js +1 -0
  120. package/dist/vite-plugin-astro/compile.js +2 -3
  121. package/dist/vite-plugin-astro/hmr.js +3 -5
  122. package/dist/vite-plugin-astro/index.js +1 -1
  123. package/dist/vite-plugin-astro/metadata.js +1 -2
  124. package/dist/vite-plugin-astro-server/base.js +1 -2
  125. package/dist/vite-plugin-astro-server/controller.js +2 -3
  126. package/dist/vite-plugin-astro-server/css.js +1 -1
  127. package/dist/vite-plugin-astro-server/request.js +1 -1
  128. package/dist/vite-plugin-astro-server/route.js +1 -2
  129. package/dist/vite-plugin-astro-server/scripts.js +2 -3
  130. package/dist/vite-plugin-astro-server/vite.js +1 -1
  131. package/dist/vite-plugin-config-alias/index.js +1 -1
  132. package/dist/vite-plugin-env/index.js +1 -1
  133. package/dist/vite-plugin-head/index.js +4 -6
  134. package/dist/vite-plugin-html/index.js +1 -2
  135. package/dist/vite-plugin-html/transform/slots.js +5 -6
  136. package/dist/vite-plugin-html/transform/utils.js +1 -2
  137. package/dist/vite-plugin-jsx/import-source.js +1 -2
  138. package/dist/vite-plugin-jsx/index.js +1 -1
  139. package/dist/vite-plugin-jsx/tag.js +4 -6
  140. package/dist/vite-plugin-markdown/index.js +1 -2
  141. package/dist/vite-plugin-scanner/index.js +2 -1
  142. package/dist/vite-plugin-scanner/scan.js +1 -1
  143. package/dist/vite-plugin-scripts/index.js +1 -1
  144. package/dist/vite-plugin-scripts/page-ssr.js +1 -1
  145. package/package.json +11 -20
  146. package/tsconfigs/base.json +8 -6
  147. package/tsconfigs/strict.json +2 -3
  148. package/dist/cli/check/print.d.ts +0 -2
  149. package/dist/cli/check/print.js +0 -95
package/astro.js CHANGED
@@ -13,8 +13,8 @@ const CI_INSTRUCTIONS = {
13
13
  };
14
14
 
15
15
  // Hardcode supported Node.js version so we don't have to read differently in CJS & ESM.
16
- const engines = '>=16.12.0';
17
- const skipSemverCheckIfAbove = 16;
16
+ const engines = '>=18.14.1';
17
+ const skipSemverCheckIfAbove = 19;
18
18
 
19
19
  /** `astro *` */
20
20
  async function main() {
@@ -15,6 +15,7 @@ import type { AstroConfigSchema } from '../core/config';
15
15
  import type { AstroTimer } from '../core/config/timer';
16
16
  import type { AstroCookies } from '../core/cookies';
17
17
  import type { LogOptions, LoggerLevel } from '../core/logger/core';
18
+ import { AstroIntegrationLogger } from '../core/logger/core';
18
19
  import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
19
20
  import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
20
21
  export type { MarkdownHeading, MarkdownMetadata, MarkdownRenderingResult, RehypePlugins, RemarkPlugins, ShikiConfig, } from '@astrojs/markdown-remark';
@@ -278,7 +279,7 @@ type ServerConfig = {
278
279
  /**
279
280
  * @name server.port
280
281
  * @type {number}
281
- * @default `3000`
282
+ * @default `4321`
282
283
  * @description
283
284
  * Set which port the dev server should listen on.
284
285
  *
@@ -843,7 +844,7 @@ export interface AstroUserConfig {
843
844
  * ```js
844
845
  * {
845
846
  * // Example: Use the function syntax to customize based on command
846
- * server: ({ command }) => ({ port: command === 'dev' ? 3000 : 4000 })
847
+ * server: ({ command }) => ({ port: command === 'dev' ? 4321 : 4000 })
847
848
  * }
848
849
  * ```
849
850
  */
@@ -863,7 +864,7 @@ export interface AstroUserConfig {
863
864
  * @docs
864
865
  * @name server.port
865
866
  * @type {number}
866
- * @default `3000`
867
+ * @default `4321`
867
868
  * @description
868
869
  * Set which port the server should listen on.
869
870
  *
@@ -911,7 +912,7 @@ export interface AstroUserConfig {
911
912
  * @docs
912
913
  * @name image.service (Experimental)
913
914
  * @type {{entrypoint: 'astro/assets/services/sharp' | 'astro/assets/services/squoosh' | string, config: Record<string, any>}}
914
- * @default `{entrypoint: 'astro/assets/services/squoosh', config?: {}}`
915
+ * @default `{entrypoint: 'astro/assets/services/sharp', config?: {}}`
915
916
  * @version 2.1.0
916
917
  * @description
917
918
  * Set which image service is used for Astro’s experimental assets support.
@@ -1300,6 +1301,16 @@ export type GetDataEntryInfoReturnType = {
1300
1301
  data: Record<string, unknown>;
1301
1302
  rawData?: string;
1302
1303
  };
1304
+ export interface AstroAdapterFeatures {
1305
+ /**
1306
+ * Creates and edge function that will communiate with the Astro middleware
1307
+ */
1308
+ edgeMiddleware: boolean;
1309
+ /**
1310
+ * SSR only. Each route becomes its own function/file.
1311
+ */
1312
+ functionPerRoute: boolean;
1313
+ }
1303
1314
  export interface AstroSettings {
1304
1315
  config: AstroConfig;
1305
1316
  adapter: AstroAdapter | undefined;
@@ -1392,7 +1403,7 @@ export type GetStaticPathsResultKeyed = GetStaticPathsResult & {
1392
1403
  *
1393
1404
  * [Astro Reference](https://docs.astro.build/en/reference/api-reference/#getstaticpaths)
1394
1405
  */
1395
- export type GetStaticPaths = (options: GetStaticPathsOptions) => Promise<GetStaticPathsResult | GetStaticPathsResult[]> | GetStaticPathsResult | GetStaticPathsResult[];
1406
+ export type GetStaticPaths = (options: GetStaticPathsOptions) => Promise<GetStaticPathsResult> | GetStaticPathsResult;
1396
1407
  /**
1397
1408
  * Infers the shape of the `params` property returned by `getStaticPaths()`.
1398
1409
  *
@@ -1511,12 +1522,49 @@ export interface Page<T = any> {
1511
1522
  }
1512
1523
  export type PaginateFunction = (data: any[], args?: PaginateOptions) => GetStaticPathsResult;
1513
1524
  export type Params = Record<string, string | undefined>;
1525
+ export type SupportsKind = 'unsupported' | 'stable' | 'experimental' | 'deprecated';
1526
+ export type AstroFeatureMap = {
1527
+ /**
1528
+ * The adapter is able serve static pages
1529
+ */
1530
+ staticOutput?: SupportsKind;
1531
+ /**
1532
+ * The adapter is able to serve pages that are static or rendered via server
1533
+ */
1534
+ hybridOutput?: SupportsKind;
1535
+ /**
1536
+ * The adapter is able to serve SSR pages
1537
+ */
1538
+ serverOutput?: SupportsKind;
1539
+ /**
1540
+ * The adapter can emit static assets
1541
+ */
1542
+ assets?: AstroAssetsFeature;
1543
+ };
1544
+ export interface AstroAssetsFeature {
1545
+ supportKind?: SupportsKind;
1546
+ /**
1547
+ * Whether if this adapter deploys files in an enviroment that is compatible with the library `sharp`
1548
+ */
1549
+ isSharpCompatible?: boolean;
1550
+ /**
1551
+ * Whether if this adapter deploys files in an enviroment that is compatible with the library `squoosh`
1552
+ */
1553
+ isSquooshCompatible?: boolean;
1554
+ }
1514
1555
  export interface AstroAdapter {
1515
1556
  name: string;
1516
1557
  serverEntrypoint?: string;
1517
1558
  previewEntrypoint?: string;
1518
1559
  exports?: string[];
1519
1560
  args?: any;
1561
+ adapterFeatures?: AstroAdapterFeatures;
1562
+ /**
1563
+ * List of features supported by an adapter.
1564
+ *
1565
+ * If the adapter is not able to handle certain configurations, Astro will throw an error.
1566
+ */
1567
+ supportedAstroFeatures?: AstroFeatureMap;
1520
1568
  }
1521
1569
  type Body = string;
1522
1570
  export type ValidRedirectStatus = 300 | 301 | 302 | 303 | 304 | 307 | 308;
@@ -1696,18 +1744,24 @@ export interface AstroIntegration {
1696
1744
  injectScript: (stage: InjectedScriptStage, content: string) => void;
1697
1745
  injectRoute: (injectRoute: InjectedRoute) => void;
1698
1746
  addClientDirective: (directive: ClientDirectiveConfig) => void;
1747
+ logger: AstroIntegrationLogger;
1699
1748
  }) => void | Promise<void>;
1700
1749
  'astro:config:done'?: (options: {
1701
1750
  config: AstroConfig;
1702
1751
  setAdapter: (adapter: AstroAdapter) => void;
1752
+ logger: AstroIntegrationLogger;
1703
1753
  }) => void | Promise<void>;
1704
1754
  'astro:server:setup'?: (options: {
1705
1755
  server: vite.ViteDevServer;
1756
+ logger: AstroIntegrationLogger;
1706
1757
  }) => void | Promise<void>;
1707
1758
  'astro:server:start'?: (options: {
1708
1759
  address: AddressInfo;
1760
+ logger: AstroIntegrationLogger;
1761
+ }) => void | Promise<void>;
1762
+ 'astro:server:done'?: (options: {
1763
+ logger: AstroIntegrationLogger;
1709
1764
  }) => void | Promise<void>;
1710
- 'astro:server:done'?: () => void | Promise<void>;
1711
1765
  'astro:build:ssr'?: (options: {
1712
1766
  manifest: SerializedSSRManifest;
1713
1767
  /**
@@ -1719,16 +1773,21 @@ export interface AstroIntegration {
1719
1773
  * File path of the emitted middleware
1720
1774
  */
1721
1775
  middlewareEntryPoint: URL | undefined;
1776
+ logger: AstroIntegrationLogger;
1777
+ }) => void | Promise<void>;
1778
+ 'astro:build:start'?: (options: {
1779
+ logger: AstroIntegrationLogger;
1722
1780
  }) => void | Promise<void>;
1723
- 'astro:build:start'?: () => void | Promise<void>;
1724
1781
  'astro:build:setup'?: (options: {
1725
1782
  vite: vite.InlineConfig;
1726
1783
  pages: Map<string, PageBuildData>;
1727
1784
  target: 'client' | 'server';
1728
1785
  updateConfig: (newConfig: vite.InlineConfig) => void;
1786
+ logger: AstroIntegrationLogger;
1729
1787
  }) => void | Promise<void>;
1730
1788
  'astro:build:generated'?: (options: {
1731
1789
  dir: URL;
1790
+ logger: AstroIntegrationLogger;
1732
1791
  }) => void | Promise<void>;
1733
1792
  'astro:build:done'?: (options: {
1734
1793
  pages: {
@@ -1736,6 +1795,7 @@ export interface AstroIntegration {
1736
1795
  }[];
1737
1796
  dir: URL;
1738
1797
  routes: RouteData[];
1798
+ logger: AstroIntegrationLogger;
1739
1799
  }) => void | Promise<void>;
1740
1800
  };
1741
1801
  }
@@ -0,0 +1 @@
1
+ import { AstroIntegrationLogger } from "../core/logger/core";
@@ -5,6 +5,11 @@ import { prependForwardSlash } from "../core/path.js";
5
5
  import { isServerLikeOutput } from "../prerender/utils.js";
6
6
  import { getConfiguredImageService, isESMImportedImage } from "./internal.js";
7
7
  async function generateImage(buildOpts, options, filepath) {
8
+ if (typeof buildOpts.settings.config.image === "undefined") {
9
+ throw new Error(
10
+ "Astro hasn't set a default service for `astro:assets`. This is an internal error and you should report it."
11
+ );
12
+ }
8
13
  if (!isESMImportedImage(options.src)) {
9
14
  return void 0;
10
15
  }
@@ -78,11 +83,10 @@ async function generateImage(buildOpts, options, filepath) {
78
83
  };
79
84
  }
80
85
  function getStaticImageList() {
81
- var _a, _b;
82
- if (!((_a = globalThis == null ? void 0 : globalThis.astroAsset) == null ? void 0 : _a.staticImages)) {
86
+ if (!globalThis?.astroAsset?.staticImages) {
83
87
  return [];
84
88
  }
85
- return (_b = globalThis.astroAsset.staticImages) == null ? void 0 : _b.entries();
89
+ return globalThis.astroAsset.staticImages?.entries();
86
90
  }
87
91
  export {
88
92
  generateImage,
@@ -2,4 +2,4 @@ import type { APIRoute } from '../@types/astro.js';
2
2
  /**
3
3
  * Endpoint used in dev and SSR to serve optimized images by the base image services
4
4
  */
5
- export declare const get: APIRoute;
5
+ export declare const GET: APIRoute;
@@ -15,7 +15,7 @@ async function loadRemoteImage(src) {
15
15
  return void 0;
16
16
  }
17
17
  }
18
- const get = async ({ request }) => {
18
+ const GET = async ({ request }) => {
19
19
  try {
20
20
  const imageService = await getConfiguredImageService();
21
21
  if (!isLocalService(imageService)) {
@@ -23,7 +23,7 @@ const get = async ({ request }) => {
23
23
  }
24
24
  const url = new URL(request.url);
25
25
  const transform = await imageService.parseURL(url, imageServiceConfig);
26
- if (!(transform == null ? void 0 : transform.src)) {
26
+ if (!transform?.src) {
27
27
  throw new Error("Incorrect transform returned by `parseURL`");
28
28
  }
29
29
  let inputBuffer = void 0;
@@ -51,5 +51,5 @@ const get = async ({ request }) => {
51
51
  }
52
52
  };
53
53
  export {
54
- get
54
+ GET
55
55
  };
@@ -12,8 +12,7 @@ function isESMImportedImage(src) {
12
12
  return typeof src === "object";
13
13
  }
14
14
  async function getConfiguredImageService() {
15
- var _a;
16
- if (!((_a = globalThis == null ? void 0 : globalThis.astroAsset) == null ? void 0 : _a.imageService)) {
15
+ if (!globalThis?.astroAsset?.imageService) {
17
16
  const { default: service } = await import(
18
17
  // @ts-expect-error
19
18
  "virtual:image-service"
@@ -0,0 +1,3 @@
1
+ import { type LocalImageService } from './service.js';
2
+ declare const noopService: LocalImageService;
3
+ export default noopService;
@@ -0,0 +1,17 @@
1
+ import { baseService } from "./service.js";
2
+ const noopService = {
3
+ validateOptions: baseService.validateOptions,
4
+ getURL: baseService.getURL,
5
+ parseURL: baseService.parseURL,
6
+ getHTMLAttributes: baseService.getHTMLAttributes,
7
+ async transform(inputBuffer, transformOptions) {
8
+ return {
9
+ data: inputBuffer,
10
+ format: transformOptions.format
11
+ };
12
+ }
13
+ };
14
+ var noop_default = noopService;
15
+ export {
16
+ noop_default as default
17
+ };
@@ -2,6 +2,9 @@ class ImageData {
2
2
  static from(input) {
3
3
  return new ImageData(input.data || input._data, input.width, input.height);
4
4
  }
5
+ _data;
6
+ width;
7
+ height;
5
8
  get data() {
6
9
  if (Object.prototype.toString.call(this._data) === "[object Object]") {
7
10
  return Buffer.from(Object.values(this._data));
@@ -18,16 +18,15 @@ function maybeDelay() {
18
18
  return Promise.resolve();
19
19
  }
20
20
  async function decodeBuffer(_buffer) {
21
- var _a;
22
21
  const buffer = Buffer.from(_buffer);
23
22
  const firstChunk = buffer.slice(0, 16);
24
23
  const firstChunkString = Array.from(firstChunk).map((v) => String.fromCodePoint(v)).join("");
25
24
  if (firstChunkString.includes("GIF")) {
26
25
  throw Error(`GIF images are not supported, please install the @astrojs/image/sharp plugin`);
27
26
  }
28
- const key = (_a = Object.entries(supportedFormats).find(
27
+ const key = Object.entries(supportedFormats).find(
29
28
  ([, { detectors }]) => detectors.some((detector) => detector.exec(firstChunkString))
30
- )) == null ? void 0 : _a[0];
29
+ )?.[0];
31
30
  if (!key) {
32
31
  throw Error(`Buffer has an unsupported format`);
33
32
  }
@@ -3,6 +3,10 @@ function uuid() {
3
3
  return Array.from({ length: 16 }, () => Math.floor(Math.random() * 256).toString(16)).join("");
4
4
  }
5
5
  class WorkerPool {
6
+ numWorkers;
7
+ jobQueue;
8
+ workerQueue;
9
+ done;
6
10
  constructor(numWorkers, workerFile) {
7
11
  this.numWorkers = numWorkers;
8
12
  this.jobQueue = new TransformStream();
@@ -26,7 +26,7 @@ function nextTag(buffer) {
26
26
  function extractTags(buffer, isBigEndian) {
27
27
  const tags = {};
28
28
  let temp = buffer;
29
- while (temp == null ? void 0 : temp.length) {
29
+ while (temp?.length) {
30
30
  const code = readUInt(temp, 16, 0, isBigEndian);
31
31
  const type = readUInt(temp, 16, 2, isBigEndian);
32
32
  const length = readUInt(temp, 32, 4, isBigEndian);
@@ -23,11 +23,11 @@ export default class Queue extends EventTarget {
23
23
  shift(): any;
24
24
  indexOf(searchElement: any, fromIndex: any): number;
25
25
  lastIndexOf(searchElement: any, fromIndex: any): number;
26
- slice(start: any, end: any): Queue;
27
- reverse(): Queue;
26
+ slice(start: any, end: any): this;
27
+ reverse(): this;
28
28
  push(...workers: any[]): number;
29
29
  unshift(...workers: any[]): number;
30
- splice(start: any, deleteCount: any, ...workers: any[]): Queue;
30
+ splice(start: any, deleteCount: any, ...workers: any[]): this;
31
31
  get length(): number;
32
32
  start(callback: any): any;
33
33
  stop(): void;
@@ -1,5 +1,5 @@
1
1
  import type * as vite from 'vite';
2
2
  import type { AstroPluginOptions } from '../@types/astro';
3
- export default function assets({ settings, logging, mode, }: AstroPluginOptions & {
3
+ export default function assets({ settings, mode, }: AstroPluginOptions & {
4
4
  mode: string;
5
5
  }): vite.Plugin[];
@@ -1,8 +1,6 @@
1
- import { bold } from "kleur/colors";
2
1
  import MagicString from "magic-string";
3
2
  import { fileURLToPath } from "node:url";
4
3
  import { normalizePath } from "vite";
5
- import { error } from "../core/logger/core.js";
6
4
  import {
7
5
  appendForwardSlash,
8
6
  joinPaths,
@@ -18,30 +16,10 @@ const rawRE = /(?:\?|&)raw(?:&|$)/;
18
16
  const urlRE = /(\?|&)url(?:&|$)/;
19
17
  function assets({
20
18
  settings,
21
- logging,
22
19
  mode
23
20
  }) {
24
- var _a;
25
21
  let resolvedConfig;
26
22
  globalThis.astroAsset = {};
27
- const UNSUPPORTED_ADAPTERS = /* @__PURE__ */ new Set([
28
- "@astrojs/cloudflare",
29
- "@astrojs/deno",
30
- "@astrojs/netlify/edge-functions",
31
- "@astrojs/vercel/edge"
32
- ]);
33
- const adapterName = (_a = settings.config.adapter) == null ? void 0 : _a.name;
34
- if (["astro/assets/services/sharp", "astro/assets/services/squoosh"].includes(
35
- settings.config.image.service.entrypoint
36
- ) && adapterName && UNSUPPORTED_ADAPTERS.has(adapterName)) {
37
- error(
38
- logging,
39
- "assets",
40
- `The currently selected adapter \`${adapterName}\` does not run on Node, however the currently used image service depends on Node built-ins. ${bold(
41
- "Your project will NOT be able to build."
42
- )}`
43
- );
44
- }
45
23
  return [
46
24
  // Expose the components and different utilities from `astro:assets` and handle serving images from `/_image` in dev
47
25
  {
@@ -58,17 +58,15 @@ const OFFICIAL_ADAPTER_TO_IMPORT_MAP = {
58
58
  deno: "@astrojs/deno"
59
59
  };
60
60
  async function getRegistry() {
61
- var _a, _b;
62
- const packageManager = ((_a = await preferredPM(process.cwd())) == null ? void 0 : _a.name) || "npm";
61
+ const packageManager = (await preferredPM(process.cwd()))?.name || "npm";
63
62
  try {
64
63
  const { stdout } = await execa(packageManager, ["config", "get", "registry"]);
65
- return ((_b = stdout == null ? void 0 : stdout.trim()) == null ? void 0 : _b.replace(/\/$/, "")) || "https://registry.npmjs.org";
64
+ return stdout?.trim()?.replace(/\/$/, "") || "https://registry.npmjs.org";
66
65
  } catch (e) {
67
66
  return "https://registry.npmjs.org";
68
67
  }
69
68
  }
70
69
  async function add(names, { flags }) {
71
- var _a;
72
70
  telemetry.record(eventCliSession("add"));
73
71
  applyPolyfill();
74
72
  if (flags.help || names.length === 0) {
@@ -145,7 +143,7 @@ async function add(names, { flags }) {
145
143
  defaultConfigContent: SVELTE_CONFIG_STUB
146
144
  });
147
145
  }
148
- if (integrations.find((integration) => integration.id === "lit") && ((_a = await preferredPM(fileURLToPath(root))) == null ? void 0 : _a.name) === "pnpm") {
146
+ if (integrations.find((integration) => integration.id === "lit") && (await preferredPM(fileURLToPath(root)))?.name === "pnpm") {
149
147
  await setupIntegrationConfig({
150
148
  root,
151
149
  logging,
@@ -186,7 +184,7 @@ async function add(names, { flags }) {
186
184
  configURL = new URL("./astro.config.mjs", root);
187
185
  await fs.writeFile(fileURLToPath(configURL), ASTRO_CONFIG_STUB, { encoding: "utf-8" });
188
186
  }
189
- if (configURL == null ? void 0 : configURL.pathname.endsWith("package.json")) {
187
+ if (configURL?.pathname.endsWith("package.json")) {
190
188
  throw new Error(
191
189
  `Unable to use "astro add" with package.json configuration. Try migrating to \`astro.config.mjs\` and try again.`
192
190
  );
@@ -594,7 +592,6 @@ async function validateIntegrations(integrations) {
594
592
  try {
595
593
  const integrationEntries = await Promise.all(
596
594
  integrations.map(async (integration) => {
597
- var _a;
598
595
  const parsed = parseIntegrationName(integration);
599
596
  if (!parsed) {
600
597
  throw new Error(`${bold(integration)} does not appear to be a valid package name!`);
@@ -646,7 +643,7 @@ async function validateIntegrations(integrations) {
646
643
  if (pkgJson["peerDependencies"]) {
647
644
  const meta = pkgJson["peerDependenciesMeta"] || {};
648
645
  for (const peer in pkgJson["peerDependencies"]) {
649
- const optional = ((_a = meta[peer]) == null ? void 0 : _a.optional) || false;
646
+ const optional = meta[peer]?.optional || false;
650
647
  const isAstro = peer === "astro";
651
648
  if (!optional && !isAstro) {
652
649
  dependencies.push([peer, pkgJson["peerDependencies"][peer]]);
@@ -743,7 +740,7 @@ ${message}`
743
740
  );
744
741
  }
745
742
  if (await askToContinue({ flags })) {
746
- await fs.writeFile((inputConfig == null ? void 0 : inputConfig.path) ?? path.join(cwd, "tsconfig.json"), output, {
743
+ await fs.writeFile(inputConfig?.path ?? path.join(cwd, "tsconfig.json"), output, {
747
744
  encoding: "utf-8"
748
745
  });
749
746
  debug("add", `Updated ${configFileName} file`);
@@ -2,7 +2,7 @@ import _build from "../../core/build/index.js";
2
2
  import { printHelp } from "../../core/messages.js";
3
3
  import { flagsToAstroInlineConfig } from "../flags.js";
4
4
  async function build({ flags }) {
5
- if ((flags == null ? void 0 : flags.help) || (flags == null ? void 0 : flags.h)) {
5
+ if (flags?.help || flags?.h) {
6
6
  printHelp({
7
7
  commandName: "astro build",
8
8
  usage: "[...flags]",
@@ -1,78 +1,2 @@
1
- /// <reference types="node" />
2
- import { AstroCheck } from '@astrojs/language-server';
3
- import fs from 'node:fs';
4
- import type { Arguments as Flags } from 'yargs-parser';
5
- import type { AstroSettings } from '../../@types/astro';
6
- import type { LogOptions } from '../../core/logger/core.js';
7
- import type { syncInternal } from '../../core/sync';
8
- export type CheckPayload = {
9
- /**
10
- * Flags passed via CLI
11
- */
12
- flags: Flags;
13
- };
14
- /**
15
- *
16
- * Types of response emitted by the checker
17
- */
18
- export declare enum CheckResult {
19
- /**
20
- * Operation finished without errors
21
- */
22
- ExitWithSuccess = 0,
23
- /**
24
- * Operation finished with errors
25
- */
26
- ExitWithError = 1,
27
- /**
28
- * The consumer should not terminate the operation
29
- */
30
- Listen = 2
31
- }
32
- /**
33
- * Checks `.astro` files for possible errors.
34
- *
35
- * If the `--watch` flag is provided, the command runs indefinitely and provides diagnostics
36
- * when `.astro` files are modified.
37
- *
38
- * Every time an astro files is modified, content collections are also generated.
39
- *
40
- * @param {CheckPayload} options Options passed {@link AstroChecker}
41
- * @param {Flags} options.flags Flags coming from the CLI
42
- */
43
- export declare function check({ flags }: CheckPayload): Promise<AstroChecker | undefined>;
44
- type CheckerConstructor = {
45
- diagnosticChecker: AstroCheck;
46
- isWatchMode: boolean;
47
- syncInternal: typeof syncInternal;
48
- settings: Readonly<AstroSettings>;
49
- logging: Readonly<LogOptions>;
50
- fileSystem: typeof fs;
51
- };
52
- /**
53
- * Responsible to check files - classic or watch mode - and report diagnostics.
54
- *
55
- * When in watch mode, the class does a whole check pass, and then starts watching files.
56
- * When a change occurs to an `.astro` file, the checker builds content collections again and lint all the `.astro` files.
57
- */
58
- export declare class AstroChecker {
59
- #private;
60
- constructor({ diagnosticChecker, isWatchMode, syncInternal, settings, fileSystem, logging, }: CheckerConstructor);
61
- /**
62
- * Check all `.astro` files once and then finishes the operation.
63
- */
64
- check(): Promise<CheckResult>;
65
- /**
66
- * Check all `.astro` files and then start watching for changes.
67
- */
68
- watch(): Promise<CheckResult>;
69
- /**
70
- * Stops the watch. It terminates the inner server.
71
- */
72
- stop(): Promise<void>;
73
- /**
74
- * Whether the checker should run in watch mode
75
- */
76
- get isWatchMode(): boolean;
77
- }
78
- export {};
1
+ import type { Arguments } from 'yargs-parser';
2
+ export declare function check(flags: Arguments): Promise<boolean | void>;