astro 4.2.5 → 4.2.7

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.
@@ -183,5 +183,5 @@ declare module 'astro:content' {
183
183
 
184
184
  type AnyEntryMap = ContentEntryMap & DataEntryMap;
185
185
 
186
- type ContentConfig = '@@CONTENT_CONFIG_TYPE@@';
186
+ export type ContentConfig = '@@CONTENT_CONFIG_TYPE@@';
187
187
  }
@@ -32,6 +32,8 @@ async function getRotationForEXIF(inputBuffer, src) {
32
32
  case 7:
33
33
  case 8:
34
34
  return { type: "rotate", numRotations: 3 };
35
+ default:
36
+ return void 0;
35
37
  }
36
38
  }
37
39
  const service = {
@@ -180,6 +180,8 @@ async function add(names, { flags }) {
180
180
  case 3 /* failure */: {
181
181
  throw createPrettyError(new Error(`Unable to install dependencies`));
182
182
  }
183
+ case 0 /* none */:
184
+ break;
183
185
  }
184
186
  const rawConfigPath = await resolveConfigPath({
185
187
  root: rootPath,
@@ -50,7 +50,7 @@ export type SSRManifest = {
50
50
  };
51
51
  export type SSRManifestI18n = {
52
52
  fallback?: Record<string, string>;
53
- routing?: RoutingStrategies;
53
+ routing: RoutingStrategies;
54
54
  locales: Locales;
55
55
  defaultLocale: string;
56
56
  };
@@ -28,7 +28,8 @@ async function collectPagesData(opts) {
28
28
  styles: [],
29
29
  propagatedStyles: /* @__PURE__ */ new Map(),
30
30
  propagatedScripts: /* @__PURE__ */ new Map(),
31
- hoistedScript: void 0
31
+ hoistedScript: void 0,
32
+ hasSharedModules: false
32
33
  };
33
34
  clearInterval(routeCollectionLogTimeout);
34
35
  if (settings.config.output === "static") {
@@ -49,7 +50,8 @@ async function collectPagesData(opts) {
49
50
  styles: [],
50
51
  propagatedStyles: /* @__PURE__ */ new Map(),
51
52
  propagatedScripts: /* @__PURE__ */ new Map(),
52
- hoistedScript: void 0
53
+ hoistedScript: void 0,
54
+ hasSharedModules: false
53
55
  };
54
56
  }
55
57
  clearInterval(dataCollectionLogTimeout);
@@ -11,8 +11,37 @@ function vitePluginPrerender(opts, internals) {
11
11
  return "astro";
12
12
  }
13
13
  const pageInfo = internals.pagesByViteID.get(id);
14
+ let hasSharedModules = false;
14
15
  if (pageInfo) {
15
16
  if (getPrerenderMetadata(meta.getModuleInfo(id))) {
17
+ const infoMeta = meta.getModuleInfo(id);
18
+ for (const moduleId of infoMeta.importedIds) {
19
+ const moduleMeta = meta.getModuleInfo(moduleId);
20
+ if (
21
+ // a shared modules should be inside the `src/` folder, at least
22
+ moduleMeta.id.startsWith(opts.settings.config.srcDir.pathname) && // and has at least two importers: the current page and something else
23
+ moduleMeta.importers.length > 1
24
+ ) {
25
+ for (const importer of moduleMeta.importedIds) {
26
+ if (importer !== id) {
27
+ const importerModuleMeta = meta.getModuleInfo(importer);
28
+ if (importerModuleMeta) {
29
+ if (importerModuleMeta.id.includes("/pages")) {
30
+ if (getPrerenderMetadata(importerModuleMeta) === false) {
31
+ hasSharedModules = true;
32
+ break;
33
+ }
34
+ } else if (importerModuleMeta.id.includes("/middleware")) {
35
+ hasSharedModules = true;
36
+ break;
37
+ }
38
+ }
39
+ }
40
+ }
41
+ }
42
+ }
43
+ opts.allPages;
44
+ pageInfo.hasSharedModules = hasSharedModules;
16
45
  pageInfo.route.prerender = true;
17
46
  return "prerender";
18
47
  }
@@ -279,7 +279,7 @@ async function runPostBuildHooks(container, ssrOutputs, clientOutputs) {
279
279
  async function cleanStaticOutput(opts, internals, ssrOutputChunkNames) {
280
280
  const allStaticFiles = /* @__PURE__ */ new Set();
281
281
  for (const pageData of eachPageData(internals)) {
282
- if (pageData.route.prerender) {
282
+ if (pageData.route.prerender && !pageData.hasSharedModules) {
283
283
  const { moduleSpecifier } = pageData;
284
284
  const pageBundleId = internals.pageToBundleMap.get(moduleSpecifier);
285
285
  const entryBundleId = internals.entrySpecifierToBundleMap.get(moduleSpecifier);
@@ -28,6 +28,7 @@ export interface PageBuildData {
28
28
  order: number;
29
29
  sheet: StylesheetAsset;
30
30
  }>;
31
+ hasSharedModules: boolean;
31
32
  }
32
33
  export type AllPagesData = Record<ComponentPath, PageBuildData>;
33
34
  /** Options for the static build */
@@ -1,3 +1,4 @@
1
1
  export declare const ASTRO_VERSION: string;
2
2
  export declare const SUPPORTED_MARKDOWN_FILE_EXTENSIONS: readonly [".markdown", ".mdown", ".mkdn", ".mkd", ".mdwn", ".md"];
3
3
  export declare const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
4
+ export declare const ROUTE_DATA_SYMBOL = "astro.routeData";
@@ -1,4 +1,4 @@
1
- const ASTRO_VERSION = "4.2.5";
1
+ const ASTRO_VERSION = "4.2.7";
2
2
  const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
3
3
  ".markdown",
4
4
  ".mdown",
@@ -8,8 +8,10 @@ const SUPPORTED_MARKDOWN_FILE_EXTENSIONS = [
8
8
  ".md"
9
9
  ];
10
10
  const MIDDLEWARE_PATH_SEGMENT_NAME = "middleware";
11
+ const ROUTE_DATA_SYMBOL = "astro.routeData";
11
12
  export {
12
13
  ASTRO_VERSION,
13
14
  MIDDLEWARE_PATH_SEGMENT_NAME,
15
+ ROUTE_DATA_SYMBOL,
14
16
  SUPPORTED_MARKDOWN_FILE_EXTENSIONS
15
17
  };
@@ -23,7 +23,7 @@ async function dev(inlineConfig) {
23
23
  base: restart.container.settings.config.base
24
24
  })
25
25
  );
26
- const currentVersion = "4.2.5";
26
+ const currentVersion = "4.2.7";
27
27
  if (currentVersion.includes("-")) {
28
28
  logger.warn("SKIP_FORMAT", msg.prerelease({ currentVersion }));
29
29
  }
@@ -36,7 +36,7 @@ function serverStart({
36
36
  host,
37
37
  base
38
38
  }) {
39
- const version = "4.2.5";
39
+ const version = "4.2.7";
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.2.5"}`
261
+ `v${"4.2.7"}`
262
262
  )} ${headline}`
263
263
  );
264
264
  }
@@ -1,7 +1,9 @@
1
1
  import { normalizeTheLocale, toCodes } from "../../i18n/index.js";
2
2
  import { AstroError, AstroErrorData } from "../errors/index.js";
3
3
  import { getParamsAndProps } from "./params-and-props.js";
4
+ import { ROUTE_DATA_SYMBOL } from "../constants.js";
4
5
  const clientLocalsSymbol = Symbol.for("astro.locals");
6
+ const routeDataSymbol = Symbol.for(ROUTE_DATA_SYMBOL);
5
7
  async function createRenderContext(options) {
6
8
  const request = options.request;
7
9
  const pathname = options.pathname ?? new URL(request.url).pathname;
@@ -148,8 +150,11 @@ function computePreferredLocaleList(request, locales) {
148
150
  return result;
149
151
  }
150
152
  function computeCurrentLocale(request, locales, routingStrategy, defaultLocale) {
151
- const requestUrl = new URL(request.url);
152
- for (const segment of requestUrl.pathname.split("/")) {
153
+ const routeData = Reflect.get(request, routeDataSymbol);
154
+ if (!routeData) {
155
+ return defaultLocale;
156
+ }
157
+ for (const segment of routeData.route.split("/")) {
153
158
  for (const locale of locales) {
154
159
  if (typeof locale === "string") {
155
160
  if (normalizeTheLocale(locale) === normalizeTheLocale(segment)) {
@@ -1,7 +1,8 @@
1
1
  import { appendForwardSlash, joinPaths } from "@astrojs/internal-helpers/path";
2
2
  import { getPathByLocale, normalizeTheLocale } from "./index.js";
3
3
  import { shouldAppendForwardSlash } from "../core/build/util.js";
4
- const routeDataSymbol = Symbol.for("astro.routeData");
4
+ import { ROUTE_DATA_SYMBOL } from "../core/constants.js";
5
+ const routeDataSymbol = Symbol.for(ROUTE_DATA_SYMBOL);
5
6
  function pathnameHasLocale(pathname, locales) {
6
7
  const segments = pathname.split("/");
7
8
  for (const segment of segments) {
@@ -3,7 +3,8 @@ import type { AstroConfig, AstroSettings } from '../@types/astro.js';
3
3
  type AstroInternationalization = {
4
4
  settings: AstroSettings;
5
5
  };
6
- export interface I18nInternalConfig extends Pick<AstroConfig, 'base' | 'site' | 'trailingSlash'>, NonNullable<AstroConfig['i18n']>, Pick<AstroConfig['build'], 'format'> {
6
+ export interface I18nInternalConfig extends Pick<AstroConfig, 'base' | 'site' | 'trailingSlash'>, Pick<AstroConfig['build'], 'format'> {
7
+ i18n: AstroConfig['i18n'];
7
8
  }
8
9
  export default function astroInternationalization({ settings, }: AstroInternationalization): vite.Plugin;
9
10
  export {};
@@ -1,8 +1,6 @@
1
1
  import { AstroError } from "../core/errors/errors.js";
2
2
  import { AstroErrorData } from "../core/errors/index.js";
3
3
  const virtualModuleId = "astro:i18n";
4
- const configId = "astro-internal:i18n-config";
5
- const resolvedConfigId = `\0${configId}`;
6
4
  function astroInternationalization({
7
5
  settings
8
6
  }) {
@@ -16,30 +14,20 @@ function astroInternationalization({
16
14
  return {
17
15
  name: "astro:i18n",
18
16
  enforce: "pre",
19
- async resolveId(id) {
17
+ config(config) {
18
+ const i18nConfig = { base, format, site, trailingSlash, i18n };
19
+ return {
20
+ define: {
21
+ __ASTRO_INTERNAL_I18N_CONFIG__: JSON.stringify(i18nConfig)
22
+ }
23
+ };
24
+ },
25
+ resolveId(id) {
20
26
  if (id === virtualModuleId) {
21
27
  if (i18n === void 0)
22
28
  throw new AstroError(AstroErrorData.i18nNotEnabled);
23
29
  return this.resolve("astro/virtual-modules/i18n.js");
24
30
  }
25
- if (id === configId)
26
- return resolvedConfigId;
27
- },
28
- load(id) {
29
- if (id === resolvedConfigId) {
30
- const { defaultLocale, locales, routing, fallback } = i18n;
31
- const config = {
32
- base,
33
- format,
34
- site,
35
- trailingSlash,
36
- defaultLocale,
37
- locales,
38
- routing,
39
- fallback
40
- };
41
- return `export default ${JSON.stringify(config)};`;
42
- }
43
31
  }
44
32
  };
45
33
  }
@@ -20,7 +20,10 @@ function coerce(key, value) {
20
20
  return true;
21
21
  if (value === "false" || value === 0)
22
22
  return false;
23
+ break;
23
24
  }
25
+ default:
26
+ throw new Error(`Incorrect value for ${key}`);
24
27
  }
25
28
  return value;
26
29
  }
@@ -42,11 +42,8 @@ const aria_non_interactive_roles = [
42
42
  "application",
43
43
  "article",
44
44
  "banner",
45
- "button",
46
45
  "cell",
47
- "checkbox",
48
46
  "columnheader",
49
- "combobox",
50
47
  "complementary",
51
48
  "contentinfo",
52
49
  "definition",
@@ -56,55 +53,30 @@ const aria_non_interactive_roles = [
56
53
  "feed",
57
54
  "figure",
58
55
  "form",
59
- "grid",
60
- "gridcell",
61
56
  "group",
62
57
  "heading",
63
58
  "img",
64
- "link",
65
59
  "list",
66
- "listbox",
67
60
  "listitem",
68
61
  "log",
69
62
  "main",
70
63
  "marquee",
71
64
  "math",
72
- "menu",
73
- "menubar",
74
- "menuitem",
75
- "menuitemcheckbox",
76
65
  "menuitemradio",
77
66
  "navigation",
78
67
  "none",
79
68
  "note",
80
- "option",
81
69
  "presentation",
82
- "progressbar",
83
- "radio",
84
- "radiogroup",
85
70
  "region",
86
71
  "row",
87
72
  "rowgroup",
88
73
  "rowheader",
89
- "scrollbar",
90
74
  "search",
91
- "searchbox",
92
- "separator",
93
- "slider",
94
- "spinbutton",
95
75
  "status",
96
- "switch",
97
- "tab",
98
- "tablist",
99
- "tabpanel",
100
76
  "term",
101
- "textbox",
102
77
  "timer",
103
78
  "toolbar",
104
- "tooltip",
105
- "tree",
106
- "treegrid",
107
- "treeitem"
79
+ "tooltip"
108
80
  ];
109
81
  const a11y_required_content = [
110
82
  // anchor-has-content
@@ -144,7 +144,10 @@ var settings_default = {
144
144
  astroToggle.input.addEventListener("change", setting.changeEvent);
145
145
  astroToggle.input.checked = settings.config[setting.settingKey];
146
146
  label.append(astroToggle);
147
+ break;
147
148
  }
149
+ default:
150
+ break;
148
151
  }
149
152
  return label;
150
153
  }
@@ -30,6 +30,8 @@ function getPrescripts(result, type, directive) {
30
30
  )};${islandScript}</script>`;
31
31
  case "directive":
32
32
  return `<script>${getDirectiveScriptText(result, directive)}</script>`;
33
+ case null:
34
+ break;
33
35
  }
34
36
  return "";
35
37
  }
@@ -1,7 +1,7 @@
1
1
  import * as I18nInternals from "../i18n/index.js";
2
2
  import { normalizeTheLocale, toCodes, toPaths } from "../i18n/index.js";
3
- import config from "astro-internal:i18n-config";
4
- const { trailingSlash, format, site, defaultLocale, locales, routing } = config;
3
+ const { trailingSlash, format, site, i18n } = __ASTRO_INTERNAL_I18N_CONFIG__;
4
+ const { defaultLocale, locales, routing } = i18n;
5
5
  const base = import.meta.env.BASE_URL;
6
6
  const getRelativeLocaleUrl = (locale, path, options) => I18nInternals.getLocaleRelativeUrl({
7
7
  locale,
@@ -52,12 +52,16 @@ ${args.error}`
52
52
  if (id === resolvedVirtualModuleId) {
53
53
  return `
54
54
  export const loadDevToolbarApps = async () => {
55
- return (await Promise.all([${settings.devToolbarApps.map((plugin) => `safeLoadPlugin(${JSON.stringify(plugin)})`).join(",")}])).filter(app => app);
55
+ return (await Promise.all([${settings.devToolbarApps.map(
56
+ (plugin) => `safeLoadPlugin(async () => (await import(${JSON.stringify(
57
+ plugin
58
+ )})).default, ${JSON.stringify(plugin)})`
59
+ ).join(",")}])).filter(app => app);
56
60
  };
57
61
 
58
- async function safeLoadPlugin(entrypoint) {
62
+ async function safeLoadPlugin(importEntrypoint, entrypoint) {
59
63
  try {
60
- const app = (await import(/* @vite-ignore */ entrypoint)).default;
64
+ const app = await importEntrypoint();
61
65
 
62
66
  if (typeof app !== 'object' || !app.id || !app.name) {
63
67
  throw new Error("Apps must default export an object with an id, and a name.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "astro",
3
- "version": "4.2.5",
3
+ "version": "4.2.7",
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",
@@ -163,7 +163,7 @@
163
163
  "yargs-parser": "^21.1.1",
164
164
  "zod": "^3.22.4",
165
165
  "@astrojs/internal-helpers": "0.2.1",
166
- "@astrojs/markdown-remark": "4.2.0",
166
+ "@astrojs/markdown-remark": "4.2.1",
167
167
  "@astrojs/telemetry": "3.0.4"
168
168
  },
169
169
  "optionalDependencies": {