astro 2.7.3 → 2.7.4

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 (78) hide show
  1. package/astro.js +0 -1
  2. package/dist/@types/astro.d.ts +1 -1
  3. package/dist/assets/image-endpoint.js +1 -1
  4. package/dist/assets/services/vendor/squoosh/codecs.js +0 -2
  5. package/dist/assets/vendor/image-size/types/tiff.js +1 -1
  6. package/dist/content/utils.d.ts +1 -1
  7. package/dist/content/utils.js +1 -1
  8. package/dist/core/app/node.d.ts +1 -1
  9. package/dist/core/build/generate.js +12 -22
  10. package/dist/core/build/plugins/index.js +3 -3
  11. package/dist/core/build/plugins/plugin-analyzer.js +1 -1
  12. package/dist/core/build/plugins/plugin-css.js +1 -1
  13. package/dist/core/build/plugins/plugin-middleware.d.ts +2 -3
  14. package/dist/core/build/plugins/plugin-middleware.js +3 -3
  15. package/dist/core/build/plugins/plugin-renderers.d.ts +2 -3
  16. package/dist/core/build/plugins/plugin-renderers.js +3 -4
  17. package/dist/core/build/plugins/plugin-ssr.js +4 -11
  18. package/dist/core/compile/compile.js +0 -1
  19. package/dist/core/config/schema.d.ts +73 -73
  20. package/dist/core/config/schema.js +0 -1
  21. package/dist/core/constants.js +1 -1
  22. package/dist/core/cookies/cookies.js +4 -2
  23. package/dist/core/create-vite.js +2 -2
  24. package/dist/core/dev/dev.js +1 -1
  25. package/dist/core/dev/restart.js +1 -1
  26. package/dist/core/errors/dev/utils.js +2 -2
  27. package/dist/core/errors/errors.d.ts +6 -6
  28. package/dist/core/errors/overlay.d.ts +1 -2
  29. package/dist/core/errors/overlay.js +3 -2
  30. package/dist/core/errors/utils.js +1 -1
  31. package/dist/core/messages.js +2 -2
  32. package/dist/core/middleware/callMiddleware.js +0 -4
  33. package/dist/core/module-loader/loader.d.ts +1 -0
  34. package/dist/core/render/context.js +2 -2
  35. package/dist/core/render/core.d.ts +1 -21
  36. package/dist/core/render/core.js +0 -63
  37. package/dist/core/render/dev/index.js +2 -1
  38. package/dist/core/render/dev/vite.js +7 -8
  39. package/dist/core/render/environment.d.ts +13 -8
  40. package/dist/core/render/environment.js +0 -19
  41. package/dist/core/render/index.d.ts +3 -2
  42. package/dist/core/render/index.js +3 -10
  43. package/dist/core/render/params-and-props.d.ts +13 -0
  44. package/dist/core/render/params-and-props.js +57 -0
  45. package/dist/core/render/result.d.ts +12 -0
  46. package/dist/core/render/route-cache.d.ts +3 -2
  47. package/dist/core/render/route-cache.js +13 -7
  48. package/dist/core/routing/manifest/create.js +2 -22
  49. package/dist/events/error.js +6 -2
  50. package/dist/runtime/client/visible.js +1 -2
  51. package/dist/runtime/client/visible.prebuilt.d.ts +1 -1
  52. package/dist/runtime/client/visible.prebuilt.js +1 -1
  53. package/dist/runtime/server/astro-global.js +1 -1
  54. package/dist/runtime/server/astro-island.js +2 -2
  55. package/dist/runtime/server/astro-island.prebuilt.d.ts +1 -1
  56. package/dist/runtime/server/astro-island.prebuilt.js +1 -1
  57. package/dist/runtime/server/endpoint.js +1 -1
  58. package/dist/runtime/server/jsx.js +1 -1
  59. package/dist/runtime/server/render/head.js +1 -1
  60. package/dist/runtime/server/render/util.js +11 -3
  61. package/dist/vite-plugin-astro/compile.js +2 -4
  62. package/dist/vite-plugin-astro/hmr.js +1 -1
  63. package/dist/vite-plugin-astro-postprocess/index.d.ts +1 -6
  64. package/dist/vite-plugin-astro-postprocess/index.js +1 -1
  65. package/dist/vite-plugin-astro-server/plugin.js +2 -2
  66. package/dist/vite-plugin-astro-server/route.js +17 -12
  67. package/dist/vite-plugin-head/index.d.ts +2 -6
  68. package/dist/vite-plugin-head/index.js +2 -4
  69. package/dist/vite-plugin-html/transform/escape.js +2 -2
  70. package/dist/vite-plugin-html/transform/slots.js +1 -1
  71. package/dist/vite-plugin-jsx/import-source.js +1 -1
  72. package/dist/vite-plugin-jsx/tag.d.ts +1 -1
  73. package/dist/vite-plugin-jsx/tag.js +1 -2
  74. package/dist/vite-plugin-markdown/content-entry-type.js +2 -3
  75. package/dist/vite-plugin-scanner/scan.js +1 -1
  76. package/dist/vite-plugin-scripts/index.js +1 -1
  77. package/dist/vite-plugin-ssr-manifest/index.js +1 -1
  78. package/package.json +1 -1
package/astro.js CHANGED
@@ -1,5 +1,4 @@
1
1
  #!/usr/bin/env node
2
- /* eslint-disable no-console */
3
2
  'use strict';
4
3
 
5
4
  // ISOMORPHIC FILE: NO TOP-LEVEL IMPORT/REQUIRE() ALLOWED
@@ -765,7 +765,7 @@ export interface AstroUserConfig {
765
765
  * @docs
766
766
  * @name build.split
767
767
  * @type {boolean}
768
- * @default {false}
768
+ * @default `false`
769
769
  * @version 2.7.0
770
770
  * @description
771
771
  * Defines how the SSR code should be bundled when built.
@@ -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 || !transform.src) {
26
+ if (!(transform == null ? void 0 : transform.src)) {
27
27
  throw new Error("Incorrect transform returned by `parseURL`");
28
28
  }
29
29
  let inputBuffer = void 0;
@@ -211,7 +211,6 @@ const codecs = {
211
211
  avif: {
212
212
  name: "AVIF",
213
213
  extension: "avif",
214
- // eslint-disable-next-line no-control-regex
215
214
  detectors: [/^\x00\x00\x00 ftypavif\x00\x00\x00\x00/],
216
215
  dec: () => instantiateEmscriptenWasm(avifDec, avifDecWasm),
217
216
  enc: async () => {
@@ -241,7 +240,6 @@ const codecs = {
241
240
  oxipng: {
242
241
  name: "OxiPNG",
243
242
  extension: "png",
244
- // eslint-disable-next-line no-control-regex
245
243
  detectors: [/^\x89PNG\x0D\x0A\x1A\x0A/],
246
244
  dec: async () => {
247
245
  await pngEncDecInit();
@@ -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 && temp.length) {
29
+ while (temp == null ? void 0 : 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);
@@ -119,7 +119,7 @@ export declare function getContentEntryIdAndSlug({ entry, contentDir, collection
119
119
  };
120
120
  export declare function getEntryType(entryPath: string, paths: Pick<ContentPaths, 'config' | 'contentDir'>, contentFileExts: string[], dataFileExts: string[], experimentalAssets?: boolean): 'content' | 'data' | 'config' | 'ignored' | 'unsupported';
121
121
  export declare function hasUnderscoreBelowContentDirectoryPath(fileUrl: URL, contentDir: ContentPaths['contentDir']): boolean;
122
- export declare function parseFrontmatter(fileContents: string, filePath: string): matter.GrayMatterFile<string>;
122
+ export declare function parseFrontmatter(fileContents: string): matter.GrayMatterFile<string>;
123
123
  /**
124
124
  * The content config is loaded separately from other `src/` files.
125
125
  * This global observable lets dependent plugins (like the content flag plugin)
@@ -209,7 +209,7 @@ function getYAMLErrorLine(rawData, objectKey) {
209
209
  const numNewlinesBeforeKey = dataBeforeKey.split("\n").length;
210
210
  return numNewlinesBeforeKey;
211
211
  }
212
- function parseFrontmatter(fileContents, filePath) {
212
+ function parseFrontmatter(fileContents) {
213
213
  try {
214
214
  matter.clearCache();
215
215
  return matter(fileContents);
@@ -7,7 +7,7 @@ declare class NodeIncomingMessage extends IncomingMessage {
7
7
  /**
8
8
  * The read-only body property of the Request interface contains a ReadableStream with the body contents that have been added to the request.
9
9
  */
10
- body?: any | undefined;
10
+ body?: unknown;
11
11
  }
12
12
  export declare class NodeApp extends App {
13
13
  match(req: NodeIncomingMessage | Request, opts?: MatchOptions): RouteData | undefined;
@@ -222,27 +222,25 @@ async function getPathsForRoute(pageData, mod, opts, builtPaths) {
222
222
  builtPaths.add(pageData.route.pathname);
223
223
  } else {
224
224
  const route = pageData.route;
225
- const result = await callGetStaticPaths({
225
+ const staticPaths = await callGetStaticPaths({
226
226
  mod,
227
- route: pageData.route,
227
+ route,
228
+ routeCache: opts.routeCache,
228
229
  isValidate: false,
229
230
  logging: opts.logging,
230
231
  ssr: isServerLikeOutput(opts.settings.config)
231
- }).then((_result) => {
232
- const label = _result.staticPaths.length === 1 ? "page" : "pages";
233
- debug(
234
- "build",
235
- `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.magenta(
236
- `[${_result.staticPaths.length} ${label}]`
237
- )}`
238
- );
239
- return _result;
240
232
  }).catch((err) => {
241
233
  debug("build", `\u251C\u2500\u2500 ${colors.bold(colors.red("\u2717"))} ${route.component}`);
242
234
  throw err;
243
235
  });
244
- opts.routeCache.set(route, result);
245
- paths = result.staticPaths.map((staticPath) => {
236
+ const label = staticPaths.length === 1 ? "page" : "pages";
237
+ debug(
238
+ "build",
239
+ `\u251C\u2500\u2500 ${colors.bold(colors.green("\u2714"))} ${route.component} \u2192 ${colors.magenta(
240
+ `[${staticPaths.length} ${label}]`
241
+ )}`
242
+ );
243
+ paths = staticPaths.map((staticPath) => {
246
244
  try {
247
245
  return route.generate(staticPath.params);
248
246
  } catch (e) {
@@ -330,15 +328,7 @@ function getUrlForPath(pathname, base, origin, format, routeType) {
330
328
  }
331
329
  async function generatePath(pathname, opts, gopts, onRequest) {
332
330
  const { settings, logging, origin, routeCache } = opts;
333
- const {
334
- mod,
335
- internals,
336
- linkIds,
337
- scripts: hoistedScripts,
338
- styles: _styles,
339
- pageData,
340
- renderers
341
- } = gopts;
331
+ const { mod, internals, scripts: hoistedScripts, styles: _styles, pageData, renderers } = gopts;
342
332
  if (pageData.route.type === "page") {
343
333
  addPageName(pathname, opts);
344
334
  }
@@ -16,11 +16,11 @@ function registerAllPlugins({ internals, options, register }) {
16
16
  register(pluginAliasResolve(internals));
17
17
  register(pluginAnalyzer(internals));
18
18
  register(pluginInternals(internals));
19
- register(pluginRenderers(options, internals));
20
- register(pluginMiddleware(options, internals));
19
+ register(pluginRenderers(options));
20
+ register(pluginMiddleware(options));
21
21
  register(pluginPages(options, internals));
22
22
  register(pluginCSS(options, internals));
23
- register(astroHeadBuildPlugin(options, internals));
23
+ register(astroHeadBuildPlugin(internals));
24
24
  register(pluginPrerender(options, internals));
25
25
  register(astroConfigBuildPlugin(options, internals));
26
26
  register(pluginHoistedScripts(options, internals));
@@ -98,7 +98,7 @@ function vitePluginAnalyzer(internals) {
98
98
  const ids = this.getModuleIds();
99
99
  for (const id of ids) {
100
100
  const info = this.getModuleInfo(id);
101
- if (!info || !((_a = info.meta) == null ? void 0 : _a.astro))
101
+ if (!((_a = info == null ? void 0 : info.meta) == null ? void 0 : _a.astro))
102
102
  continue;
103
103
  const astro = info.meta.astro;
104
104
  const pageData = getPageDataByViteID(internals, id);
@@ -64,7 +64,7 @@ function rollupPluginAstroBuildCSS(options) {
64
64
  });
65
65
  },
66
66
  async generateBundle(_outputOptions, bundle) {
67
- for (const [_, chunk] of Object.entries(bundle)) {
67
+ for (const [, chunk] of Object.entries(bundle)) {
68
68
  if (chunk.type !== "chunk")
69
69
  continue;
70
70
  if ("viteMetadata" in chunk === false)
@@ -1,7 +1,6 @@
1
1
  import type { Plugin as VitePlugin } from 'vite';
2
- import type { BuildInternals } from '../internal.js';
3
2
  import type { AstroBuildPlugin } from '../plugin';
4
3
  import type { StaticBuildOptions } from '../types';
5
4
  export declare const MIDDLEWARE_MODULE_ID = "@astro-middleware";
6
- export declare function vitePluginMiddleware(opts: StaticBuildOptions, _internals: BuildInternals): VitePlugin;
7
- export declare function pluginMiddleware(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
5
+ export declare function vitePluginMiddleware(opts: StaticBuildOptions): VitePlugin;
6
+ export declare function pluginMiddleware(opts: StaticBuildOptions): AstroBuildPlugin;
@@ -2,7 +2,7 @@ import { MIDDLEWARE_PATH_SEGMENT_NAME } from "../../constants.js";
2
2
  import { addRollupInput } from "../add-rollup-input.js";
3
3
  const MIDDLEWARE_MODULE_ID = "@astro-middleware";
4
4
  const EMPTY_MIDDLEWARE = "\0empty-middleware";
5
- function vitePluginMiddleware(opts, _internals) {
5
+ function vitePluginMiddleware(opts) {
6
6
  return {
7
7
  name: "@astro/plugin-middleware",
8
8
  options(options) {
@@ -30,13 +30,13 @@ function vitePluginMiddleware(opts, _internals) {
30
30
  }
31
31
  };
32
32
  }
33
- function pluginMiddleware(opts, internals) {
33
+ function pluginMiddleware(opts) {
34
34
  return {
35
35
  build: "ssr",
36
36
  hooks: {
37
37
  "build:before": () => {
38
38
  return {
39
- vitePlugin: vitePluginMiddleware(opts, internals)
39
+ vitePlugin: vitePluginMiddleware(opts)
40
40
  };
41
41
  }
42
42
  }
@@ -1,8 +1,7 @@
1
1
  import type { Plugin as VitePlugin } from 'vite';
2
- import type { BuildInternals } from '../internal.js';
3
2
  import type { AstroBuildPlugin } from '../plugin';
4
3
  import type { StaticBuildOptions } from '../types';
5
4
  export declare const RENDERERS_MODULE_ID = "@astro-renderers";
6
5
  export declare const RESOLVED_RENDERERS_MODULE_ID: string;
7
- export declare function vitePluginRenderers(opts: StaticBuildOptions, _internals: BuildInternals): VitePlugin;
8
- export declare function pluginRenderers(opts: StaticBuildOptions, internals: BuildInternals): AstroBuildPlugin;
6
+ export declare function vitePluginRenderers(opts: StaticBuildOptions): VitePlugin;
7
+ export declare function pluginRenderers(opts: StaticBuildOptions): AstroBuildPlugin;
@@ -1,8 +1,7 @@
1
1
  import { addRollupInput } from "../add-rollup-input.js";
2
2
  const RENDERERS_MODULE_ID = "@astro-renderers";
3
3
  const RESOLVED_RENDERERS_MODULE_ID = `\0${RENDERERS_MODULE_ID}`;
4
- let inputs = /* @__PURE__ */ new Set();
5
- function vitePluginRenderers(opts, _internals) {
4
+ function vitePluginRenderers(opts) {
6
5
  return {
7
6
  name: "@astro/plugin-renderers",
8
7
  options(options) {
@@ -34,13 +33,13 @@ ${exports.join("\n")}`;
34
33
  }
35
34
  };
36
35
  }
37
- function pluginRenderers(opts, internals) {
36
+ function pluginRenderers(opts) {
38
37
  return {
39
38
  build: "ssr",
40
39
  hooks: {
41
40
  "build:before": () => {
42
41
  return {
43
- vitePlugin: vitePluginRenderers(opts, internals)
42
+ vitePlugin: vitePluginRenderers(opts)
44
43
  };
45
44
  }
46
45
  }
@@ -31,10 +31,7 @@ function vitePluginSSR(internals, adapter, options) {
31
31
  },
32
32
  async load(id) {
33
33
  if (id === RESOLVED_SSR_VIRTUAL_MODULE_ID) {
34
- const {
35
- settings: { config },
36
- allPages
37
- } = options;
34
+ const { allPages } = options;
38
35
  const imports = [];
39
36
  const contents = [];
40
37
  const exports = [];
@@ -66,7 +63,7 @@ function vitePluginSSR(internals, adapter, options) {
66
63
  return void 0;
67
64
  },
68
65
  async generateBundle(_opts, bundle) {
69
- for (const [_chunkName, chunk] of Object.entries(bundle)) {
66
+ for (const [, chunk] of Object.entries(bundle)) {
70
67
  if (chunk.type === "asset") {
71
68
  internals.staticFiles.add(chunk.fileName);
72
69
  }
@@ -141,10 +138,6 @@ function vitePluginSSRSplit(internals, adapter, options) {
141
138
  },
142
139
  async load(id) {
143
140
  if (id.startsWith(RESOLVED_SPLIT_MODULE_ID)) {
144
- const {
145
- settings: { config },
146
- allPages
147
- } = options;
148
141
  const imports = [];
149
142
  const contents = [];
150
143
  const exports = [];
@@ -162,7 +155,7 @@ function vitePluginSSRSplit(internals, adapter, options) {
162
155
  return void 0;
163
156
  },
164
157
  async generateBundle(_opts, bundle) {
165
- for (const [_chunkName, chunk] of Object.entries(bundle)) {
158
+ for (const [, chunk] of Object.entries(bundle)) {
166
159
  if (chunk.type === "asset") {
167
160
  internals.staticFiles.add(chunk.fileName);
168
161
  }
@@ -215,7 +208,7 @@ function pluginSSRSplit(options, internals) {
215
208
  logging: options.logging,
216
209
  entryPoints: internals.entryPoints
217
210
  });
218
- for (const [moduleName, chunk] of internals.ssrSplitEntryChunks) {
211
+ for (const [, chunk] of internals.ssrSplitEntryChunks) {
219
212
  const code = injectManifest(manifest, chunk);
220
213
  mutate(chunk, "server", code);
221
214
  }
@@ -68,7 +68,6 @@ function handleCompileResultErrors(result, cssTransformErrors) {
68
68
  case 0:
69
69
  break;
70
70
  case 1: {
71
- const error = cssTransformErrors[0];
72
71
  throw cssTransformErrors[0];
73
72
  }
74
73
  default: {