0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-30 22:03:56 -05:00

[ci] release (beta) (#9228)

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Houston (Bot) 2023-11-29 10:50:18 -08:00 committed by GitHub
parent 3b77889b47
commit c495f1ac17
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 341 additions and 148 deletions

View file

@ -32,20 +32,30 @@
"changesets": [
"angry-swans-fry",
"beige-jokes-report",
"big-cooks-notice",
"brown-jars-lick",
"calm-baboons-watch",
"clever-beds-notice",
"famous-eels-trade",
"gentle-cobras-wash",
"giant-snails-perform",
"grumpy-seas-switch",
"khaki-fans-sell",
"light-ties-poke",
"modern-candles-sip",
"odd-rivers-happen",
"plenty-candles-help",
"rude-hairs-whisper",
"sharp-starfishes-compete",
"shiny-trees-sip",
"short-deers-whisper",
"slow-hornets-try",
"sour-games-burn",
"spicy-starfishes-shake",
"tasty-dryers-bathe",
"three-chairs-sip",
"tricky-dragons-explain",
"weak-wolves-bow",
"wicked-sloths-develop",
"wild-apricots-rescue"
]

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -14,6 +14,6 @@
"@astrojs/mdx": "^2.0.0-beta.0",
"@astrojs/rss": "^4.0.0-beta.0",
"@astrojs/sitemap": "^3.0.3",
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
},
"peerDependencies": {
"astro": "^3.0.0"

View file

@ -14,6 +14,6 @@
"@astrojs/alpinejs": "^0.3.1",
"@types/alpinejs": "^3.13.5",
"alpinejs": "^3.13.3",
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/lit": "^3.0.3",
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"lit": "^2.8.0"
}
}

View file

@ -16,7 +16,7 @@
"@astrojs/solid-js": "^3.0.2",
"@astrojs/svelte": "^5.0.0-beta.0",
"@astrojs/vue": "^4.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"preact": "^10.19.2",
"react": "^18.2.0",
"react-dom": "^18.2.0",

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.0.1",
"@preact/signals": "^1.2.1",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"preact": "^10.19.2"
}
}

View file

@ -14,7 +14,7 @@
"@astrojs/react": "^3.0.7-beta.0",
"@types/react": "^18.2.37",
"@types/react-dom": "^18.2.15",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^3.0.2",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"solid-js": "^1.8.5"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/svelte": "^5.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"svelte": "^4.2.5"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/vue": "^4.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"vue": "^3.3.8"
}
}

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"@astrojs/node": "^7.0.0-beta.0",
"astro": "^4.0.0-beta.1"
"@astrojs/node": "^7.0.0-beta.1",
"astro": "^4.0.0-beta.2"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
},
"peerDependencies": {
"astro": "^3.0.0"

View file

@ -12,8 +12,8 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"@astrojs/node": "^7.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"@astrojs/node": "^7.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"html-minifier": "^4.0.0"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -12,9 +12,9 @@
"server": "node dist/server/entry.mjs"
},
"dependencies": {
"@astrojs/node": "^7.0.0-beta.0",
"@astrojs/node": "^7.0.0-beta.1",
"@astrojs/svelte": "^5.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"svelte": "^4.2.5"
}
}

View file

@ -11,7 +11,7 @@
},
"devDependencies": {
"@astrojs/tailwind": "^6.0.0-beta.0",
"@astrojs/node": "^7.0.0-beta.0",
"astro": "^4.0.0-beta.1"
"@astrojs/node": "^7.0.0-beta.1",
"astro": "^4.0.0-beta.2"
}
}

View file

@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/markdoc": "^1.0.0-beta.0",
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/markdown-remark": "^4.0.0-beta.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"hast-util-select": "^6.0.2",
"rehype-autolink-headings": "^7.1.0",
"rehype-slug": "^6.0.0",

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1"
"astro": "^4.0.0-beta.2"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/mdx": "^2.0.0-beta.0",
"@astrojs/preact": "^3.0.1",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"preact": "^10.19.2"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.0.1",
"@nanostores/preact": "^0.5.0",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"nanostores": "^0.9.5",
"preact": "^10.19.2"
}

View file

@ -14,7 +14,7 @@
"@astrojs/mdx": "^2.0.0-beta.0",
"@astrojs/tailwind": "^6.0.0-beta.0",
"@types/canvas-confetti": "^1.6.3",
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"autoprefixer": "^10.4.15",
"canvas-confetti": "^1.9.1",
"postcss": "^8.4.28",

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"vite-plugin-pwa": "0.17.0",
"workbox-window": "^7.0.0"
}

View file

@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^4.0.0-beta.1",
"astro": "^4.0.0-beta.2",
"vitest": "^0.34.2"
}
}

View file

@ -1,5 +1,60 @@
# astro
## 4.0.0-beta.2
### Major Changes
- [#9225](https://github.com/withastro/astro/pull/9225) [`c421a3d17`](https://github.com/withastro/astro/commit/c421a3d17911aeda29b5204f6d568ae87e329eaf) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Removes the opt-in `handleForms` property for `<ViewTransitions />`. Form submissions are now handled by default and can be disabled by setting `data-astro-reload` on relevant `<form />` elements.
- [#9199](https://github.com/withastro/astro/pull/9199) [`49aa215a0`](https://github.com/withastro/astro/commit/49aa215a01ee1c4805316c85bb0aea6cfbc25a31) Thanks [@lilnasy](https://github.com/lilnasy)! - This change only affects maintainers of third-party adapters. In the Integration API, the `app.render()` method of the `App` class has been simplified.
Instead of two optional arguments, it now takes a single optional argument that is an object with two optional properties: `routeData` and `locals`.
```diff
app.render(request)
- app.render(request, routeData)
+ app.render(request, { routeData })
- app.render(request, routeData, locals)
+ app.render(request, { routeData, locals })
- app.render(request, undefined, locals)
+ app.render(request, { locals })
```
The current signature is deprecated but will continue to function until next major version.
- [#9212](https://github.com/withastro/astro/pull/9212) [`c0383ea0c`](https://github.com/withastro/astro/commit/c0383ea0c102cb62b7235823c706a090ba08715f) Thanks [@alexanderniebuhr](https://github.com/alexanderniebuhr)! - Removes deprecated `app.match()` option, `matchNotFound`
### Minor Changes
- [#9115](https://github.com/withastro/astro/pull/9115) [`3b77889b4`](https://github.com/withastro/astro/commit/3b77889b47750ed6e17c7858780dc4aae9201b58) Thanks [@natemoo-re](https://github.com/natemoo-re)! - Adds the `astro preferences` command to manage user preferences. User preferences are specific to individual Astro users, unlike the `astro.config.mjs` file which changes behavior for everyone working on a project.
User preferences are scoped to the current project by default, stored in a local `.astro/settings.json` file. Using the `--global` flag, user preferences can also be applied to every Astro project on the current machine. Global user preferences are stored in an operating system-specific location.
```sh
# Disable the dev overlay for the current user in the current project
npm run astro preferences disable devOverlay
# Disable the dev overlay for the current user in all Astro projects on this machine
npm run astro preferences --global disable devOverlay
# Check if the dev overlay is enabled for the current user
npm run astro preferences list devOverlay
```
- [#9129](https://github.com/withastro/astro/pull/9129) [`8bfc20511`](https://github.com/withastro/astro/commit/8bfc20511918d675202cdc100d4efab293e5cbac) Thanks [@FredKSchott](https://github.com/FredKSchott)! - Update error log formatting
### Patch Changes
- [#9222](https://github.com/withastro/astro/pull/9222) [`279e3c1b3`](https://github.com/withastro/astro/commit/279e3c1b3d06e7b48f01c0ef8285c3719ac74ace) Thanks [@matthewp](https://github.com/matthewp)! - Ensure the dev-overlay-window is anchored to the bottom
- [#9218](https://github.com/withastro/astro/pull/9218) [`f4401c8c1`](https://github.com/withastro/astro/commit/f4401c8c1fa203431b4e7b2e89381a91b4ef1ac6) Thanks [@matthewp](https://github.com/matthewp)! - Improve high contrast mode with the Dev Overlay
- [#9227](https://github.com/withastro/astro/pull/9227) [`4b8a42406`](https://github.com/withastro/astro/commit/4b8a42406bbdcc68604ea4ecc2a926721fbc4d52) Thanks [@matthewp](https://github.com/matthewp)! - Ensure overlay x-ray z-index is higher than the island
- [#9214](https://github.com/withastro/astro/pull/9214) [`4fe523b00`](https://github.com/withastro/astro/commit/4fe523b0064b323ee46b2574339d96ea8bdb7b2d) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fixes a number of small user experience bugs with the dev overlay
## 4.0.0-beta.1
### Patch Changes

View file

@ -5,7 +5,7 @@ const test = testFactory({
root: './fixtures/astro-envs/',
devOverlay: {
enabled: false,
}
},
});
let devServer;

View file

@ -1,6 +1,6 @@
{
"name": "astro",
"version": "4.0.0-beta.1",
"version": "4.0.0-beta.2",
"description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.",
"type": "module",
"author": "withastro",

View file

@ -119,7 +119,7 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
}
case 'preferences': {
const { preferences } = await import('./preferences/index.js');
const [subcommand, key, value] = flags._.slice(3).map(v => v.toString());
const [subcommand, key, value] = flags._.slice(3).map((v) => v.toString());
const exitCode = await preferences(subcommand, key, value, { flags });
return process.exit(exitCode);
}

View file

@ -21,14 +21,27 @@ interface PreferencesOptions {
flags: yargs.Arguments;
}
const PREFERENCES_SUBCOMMANDS = ['get', 'set', 'enable', 'disable', 'delete', 'reset', 'list'] as const;
export type Subcommand = typeof PREFERENCES_SUBCOMMANDS[number];
const PREFERENCES_SUBCOMMANDS = [
'get',
'set',
'enable',
'disable',
'delete',
'reset',
'list',
] as const;
export type Subcommand = (typeof PREFERENCES_SUBCOMMANDS)[number];
function isValidSubcommand(subcommand: string): subcommand is Subcommand {
return PREFERENCES_SUBCOMMANDS.includes(subcommand as Subcommand);
}
export async function preferences(subcommand: string, key: string, value: string | undefined, { flags }: PreferencesOptions): Promise<number> {
export async function preferences(
subcommand: string,
key: string,
value: string | undefined,
{ flags }: PreferencesOptions
): Promise<number> {
if (!isValidSubcommand(subcommand) || flags?.help || flags?.h) {
msg.printHelp({
commandName: 'astro preferences',
@ -44,7 +57,10 @@ export async function preferences(subcommand: string, key: string, value: string
['disable [key]', 'Set a boolean preference to false'],
],
Flags: [
['--global', 'Scope command to global preferences (all Astro projects) rather than the current project'],
[
'--global',
'Scope command to global preferences (all Astro projects) rather than the current project',
],
],
},
});
@ -57,8 +73,8 @@ export async function preferences(subcommand: string, key: string, value: string
const settings = await createSettings(astroConfig, fileURLToPath(astroConfig.root));
const opts: SubcommandOptions = {
location: flags.global ? 'global' : undefined,
json: flags.json
}
json: flags.json,
};
if (subcommand === 'list') {
return listPreferences(settings, opts);
@ -75,17 +91,27 @@ export async function preferences(subcommand: string, key: string, value: string
if (subcommand === 'set' && value === undefined) {
const type = typeof dlv(DEFAULT_PREFERENCES, key);
console.error(msg.formatErrorMessage(collectErrorMetadata(new Error(`Please provide a ${type} value for "${key}"`)), true));
console.error(
msg.formatErrorMessage(
collectErrorMetadata(new Error(`Please provide a ${type} value for "${key}"`)),
true
)
);
return 1;
}
switch (subcommand) {
case 'get': return getPreference(settings, key, opts);
case 'set': return setPreference(settings, key, value, opts);
case 'get':
return getPreference(settings, key, opts);
case 'set':
return setPreference(settings, key, value, opts);
case 'reset':
case 'delete': return resetPreference(settings, key, opts);
case 'enable': return enablePreference(settings, key, opts);
case 'disable': return disablePreference(settings, key, opts);
case 'delete':
return resetPreference(settings, key, opts);
case 'enable':
return enablePreference(settings, key, opts);
case 'disable':
return disablePreference(settings, key, opts);
}
}
@ -95,7 +121,11 @@ interface SubcommandOptions {
}
// Default `location` to "project" to avoid reading default preferencesa
async function getPreference(settings: AstroSettings, key: PreferenceKey, { location = 'project' }: SubcommandOptions) {
async function getPreference(
settings: AstroSettings,
key: PreferenceKey,
{ location = 'project' }: SubcommandOptions
) {
try {
let value = await settings.preferences.get(key, { location });
if (value && typeof value === 'object' && !Array.isArray(value)) {
@ -117,15 +147,20 @@ async function getPreference(settings: AstroSettings, key: PreferenceKey, { loca
return 1;
}
async function setPreference(settings: AstroSettings, key: PreferenceKey, value: unknown, { location }: SubcommandOptions) {
async function setPreference(
settings: AstroSettings,
key: PreferenceKey,
value: unknown,
{ location }: SubcommandOptions
) {
try {
const defaultType = typeof dlv(DEFAULT_PREFERENCES, key);
if (typeof coerce(key, value) !== defaultType) {
throw new Error(`${key} expects a "${defaultType}" value!`)
throw new Error(`${key} expects a "${defaultType}" value!`);
}
await settings.preferences.set(key, coerce(key, value), { location });
console.log(msg.preferenceSet(key, value))
console.log(msg.preferenceSet(key, value));
return 0;
} catch (e) {
if (e instanceof Error) {
@ -136,34 +171,45 @@ async function setPreference(settings: AstroSettings, key: PreferenceKey, value:
}
}
async function enablePreference(settings: AstroSettings, key: PreferenceKey, { location }: SubcommandOptions) {
async function enablePreference(
settings: AstroSettings,
key: PreferenceKey,
{ location }: SubcommandOptions
) {
try {
await settings.preferences.set(key, true, { location });
console.log(msg.preferenceEnabled(key.replace('.enabled', '')))
console.log(msg.preferenceEnabled(key.replace('.enabled', '')));
return 0;
} catch {}
return 1;
}
async function disablePreference(settings: AstroSettings, key: PreferenceKey, { location }: SubcommandOptions) {
async function disablePreference(
settings: AstroSettings,
key: PreferenceKey,
{ location }: SubcommandOptions
) {
try {
await settings.preferences.set(key, false, { location });
console.log(msg.preferenceDisabled(key.replace('.enabled', '')))
console.log(msg.preferenceDisabled(key.replace('.enabled', '')));
return 0;
} catch {}
return 1;
}
async function resetPreference(settings: AstroSettings, key: PreferenceKey, { location }: SubcommandOptions) {
async function resetPreference(
settings: AstroSettings,
key: PreferenceKey,
{ location }: SubcommandOptions
) {
try {
await settings.preferences.set(key, undefined as any, { location });
console.log(msg.preferenceReset(key))
console.log(msg.preferenceReset(key));
return 0;
} catch {}
return 1;
}
async function listPreferences(settings: AstroSettings, { location, json }: SubcommandOptions) {
const store = await settings.preferences.getAll({ location });
if (json) {
@ -195,18 +241,34 @@ const chars = {
topRight: '╮',
bottomLeft: '╰',
bottomRight: '╯',
}
};
function formatTable(object: Record<string, string | number | boolean>, columnLabels: [string, string]) {
function formatTable(
object: Record<string, string | number | boolean>,
columnLabels: [string, string]
) {
const [colA, colB] = columnLabels;
const colALength = [colA, ...Object.keys(object)].reduce(longest, 0) + 3;
const colBLength = [colB, ...Object.values(object)].reduce(longest, 0) + 3;
function formatRow(i: number, a: string, b: string | number | boolean, style: (value: string | number | boolean) => string = (v) => v.toString()): string {
return `${chars.v} ${style(a)} ${space(colALength - a.length - 2)} ${chars.v} ${style(b)} ${space(colBLength - b.toString().length - 3)} ${chars.v}`
function formatRow(
i: number,
a: string,
b: string | number | boolean,
style: (value: string | number | boolean) => string = (v) => v.toString()
): string {
return `${chars.v} ${style(a)} ${space(colALength - a.length - 2)} ${chars.v} ${style(
b
)} ${space(colBLength - b.toString().length - 3)} ${chars.v}`;
}
const top = `${chars.topLeft}${chars.h.repeat(colALength + 1)}${chars.hBottom}${chars.h.repeat(colBLength)}${chars.topRight}`
const bottom = `${chars.bottomLeft}${chars.h.repeat(colALength + 1)}${chars.hTop}${chars.h.repeat(colBLength)}${chars.bottomRight}`
const divider = `${chars.vRightThick}${chars.hThick.repeat(colALength + 1)}${chars.hThickCross}${chars.hThick.repeat(colBLength)}${chars.vLeftThick}`
const top = `${chars.topLeft}${chars.h.repeat(colALength + 1)}${chars.hBottom}${chars.h.repeat(
colBLength
)}${chars.topRight}`;
const bottom = `${chars.bottomLeft}${chars.h.repeat(colALength + 1)}${chars.hTop}${chars.h.repeat(
colBLength
)}${chars.bottomRight}`;
const divider = `${chars.vRightThick}${chars.hThick.repeat(colALength + 1)}${
chars.hThickCross
}${chars.hThick.repeat(colBLength)}${chars.vLeftThick}`;
const rows: string[] = [top, formatRow(-1, colA, colB, bold), divider];
let i = 0;
for (const [key, value] of Object.entries(object)) {

View file

@ -147,25 +147,31 @@ export class App {
return routeData;
}
async render(request: Request, options?: RenderOptions): Promise<Response>
async render(request: Request, options?: RenderOptions): Promise<Response>;
/**
* @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
* See https://github.com/withastro/astro/pull/9199 for more information.
*/
async render(request: Request, routeData?: RouteData, locals?: object): Promise<Response>
async render(request: Request, routeDataOrOptions?: RouteData | RenderOptions, maybeLocals?: object): Promise<Response> {
async render(request: Request, routeData?: RouteData, locals?: object): Promise<Response>;
async render(
request: Request,
routeDataOrOptions?: RouteData | RenderOptions,
maybeLocals?: object
): Promise<Response> {
let routeData: RouteData | undefined;
let locals: object | undefined;
if (routeDataOrOptions && ('routeData' in routeDataOrOptions || 'locals' in routeDataOrOptions)) {
if (
routeDataOrOptions &&
('routeData' in routeDataOrOptions || 'locals' in routeDataOrOptions)
) {
if ('routeData' in routeDataOrOptions) {
routeData = routeDataOrOptions.routeData;
}
if ('locals' in routeDataOrOptions) {
locals = routeDataOrOptions.locals;
}
}
else {
} else {
routeData = routeDataOrOptions as RouteData | undefined;
locals = maybeLocals;
if (routeDataOrOptions || locals) {
@ -242,7 +248,10 @@ export class App {
#logRenderOptionsDeprecationWarning() {
if (this.#renderOptionsDeprecationWarningShown) return;
this.#logger.warn("deprecated", `The adapter ${this.#manifest.adapterName} is using a deprecated signature of the 'app.render()' method. From Astro 4.0, locals and routeData are provided as properties on an optional object to this method. Using the old signature will cause an error in Astro 5.0. See https://github.com/withastro/astro/pull/9199 for more information.`)
this.#logger.warn(
'deprecated',
`The adapter ${this.#manifest.adapterName} is using a deprecated signature of the 'app.render()' method. From Astro 4.0, locals and routeData are provided as properties on an optional object to this method. Using the old signature will cause an error in Astro 5.0. See https://github.com/withastro/astro/pull/9199 for more information.`
);
this.#renderOptionsDeprecationWarningShown = true;
}

View file

@ -117,13 +117,21 @@ export class NodeApp extends App {
}
return super.match(req);
}
render(request: NodeIncomingMessage | Request, options?: RenderOptions): Promise<Response>
render(request: NodeIncomingMessage | Request, options?: RenderOptions): Promise<Response>;
/**
* @deprecated Instead of passing `RouteData` and locals individually, pass an object with `routeData` and `locals` properties.
* See https://github.com/withastro/astro/pull/9199 for more information.
*/
render(request: NodeIncomingMessage | Request, routeData?: RouteData, locals?: object): Promise<Response>
render(req: NodeIncomingMessage | Request, routeDataOrOptions?: RouteData | RenderOptions, maybeLocals?: object) {
render(
request: NodeIncomingMessage | Request,
routeData?: RouteData,
locals?: object
): Promise<Response>;
render(
req: NodeIncomingMessage | Request,
routeDataOrOptions?: RouteData | RenderOptions,
maybeLocals?: object
) {
if (!(req instanceof Request)) {
req = createRequestFromNodeRequest(req);
}

View file

@ -47,8 +47,8 @@ export function shouldRestartContainer(
// Otherwise, watch for any astro.config.* file changes in project root
else {
const normalizedChangedFile = vite.normalizePath(changedFile);
shouldRestart = configRE.test(normalizedChangedFile) || preferencesRE.test(normalizedChangedFile);
shouldRestart =
configRE.test(normalizedChangedFile) || preferencesRE.test(normalizedChangedFile);
}
if (!shouldRestart && settings.watchFiles.length > 0) {
@ -74,7 +74,10 @@ export async function restartContainer(container: Container): Promise<Container
const error = createSafeError(_err);
// Print all error messages except ZodErrors from AstroConfig as the pre-logged error is sufficient
if (!isAstroConfigZodError(_err)) {
logger.error('config', formatErrorMessage(collectErrorMetadata(error), logger.level() === 'debug') + '\n');
logger.error(
'config',
formatErrorMessage(collectErrorMetadata(error), logger.level() === 'debug') + '\n'
);
}
// Inform connected clients of the config error
container.viteServer.ws.send({

View file

@ -128,7 +128,9 @@ export function preferenceDefaultIntro(name: string) {
}
export function preferenceDefault(name: string, value: any) {
return `${yellow('◯')} ${name} has not been set. It defaults to ${bgYellow(black(` ${JSON.stringify(value)} `))}\n`;
return `${yellow('◯')} ${name} has not been set. It defaults to ${bgYellow(
black(` ${JSON.stringify(value)} `)
)}\n`;
}
export function preferenceDisabled(name: string) {
@ -219,7 +221,10 @@ export function formatConfigErrorMessage(err: ZodError) {
// a regex to match the first line of a stack trace
const STACK_LINE_REGEXP = /^\s+at /g;
const IRRELEVANT_STACK_REGEXP = /(node_modules|astro[\/\\]dist)/g;
function formatErrorStackTrace(err: Error | ErrorWithMetadata, showFullStacktrace: boolean): string {
function formatErrorStackTrace(
err: Error | ErrorWithMetadata,
showFullStacktrace: boolean
): string {
const stackLines = (err.stack || '').split('\n').filter((line) => STACK_LINE_REGEXP.test(line));
// If full details are required, just return the entire stack trace.
if (showFullStacktrace) {
@ -230,18 +235,23 @@ function formatErrorStackTrace(err: Error | ErrorWithMetadata, showFullStacktrac
if (irrelevantStackIndex <= 0) {
const errorId = (err as ErrorWithMetadata).id;
const errorLoc = (err as ErrorWithMetadata).loc;
if (errorId|| errorLoc?.file) {
const prettyLocation = ` at ${errorId?? errorLoc?.file}${
if (errorId || errorLoc?.file) {
const prettyLocation = ` at ${errorId ?? errorLoc?.file}${
errorLoc?.line && errorLoc.column ? `:${errorLoc.line}:${errorLoc.column}` : ''
}`;
return prettyLocation + '\n [...] See full stack trace in the browser, or rerun with --verbose.';
return (
prettyLocation + '\n [...] See full stack trace in the browser, or rerun with --verbose.'
);
} else {
return stackLines.join('\n');
}
}
// If the error occurred inside of a dependency, grab the entire stack.
// Otherwise, only grab the part of the stack that is relevant to the user's codebase.
return stackLines.splice(0, irrelevantStackIndex).join('\n') + '\n [...] See full stack trace in the browser, or rerun with --verbose.';
return (
stackLines.splice(0, irrelevantStackIndex).join('\n') +
'\n [...] See full stack trace in the browser, or rerun with --verbose.'
);
}
export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: boolean): string {
@ -256,9 +266,7 @@ export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: b
if (err.hint) {
output.push(` ${bold('Hint:')}`);
output.push(
yellow(padMultilineString(renderErrorMarkdown(err.hint, 'cli'), 4))
);
output.push(yellow(padMultilineString(renderErrorMarkdown(err.hint, 'cli'), 4)));
}
const docsLink = getDocsForError(err);
@ -276,9 +284,10 @@ export function formatErrorMessage(err: ErrorWithMetadata, showFullStacktrace: b
output.push(` ${bold('Caused by:')}`);
let causeMessage = ' ';
if (err.cause instanceof Error) {
causeMessage += err.cause.message + '\n' + formatErrorStackTrace(err.cause, showFullStacktrace);
causeMessage +=
err.cause.message + '\n' + formatErrorStackTrace(err.cause, showFullStacktrace);
} else {
causeMessage += (JSON.stringify(err.cause));
causeMessage += JSON.stringify(err.cause);
}
output.push(dim(causeMessage));
}

View file

@ -3,6 +3,6 @@ export const DEFAULT_PREFERENCES = {
/** Specifies whether the user has the Dev Overlay enabled */
enabled: true,
},
}
};
export type Preferences = typeof DEFAULT_PREFERENCES;

View file

@ -9,14 +9,18 @@ import dget from 'dlv';
import { DEFAULT_PREFERENCES, type Preferences } from './defaults.js';
import { PreferenceStore } from './store.js';
type DotKeys<T> = T extends object ? { [K in keyof T]:
`${Exclude<K, symbol>}${DotKeys<T[K]> extends never ? "" : `.${DotKeys<T[K]>}`}`
}[keyof T] : never
type DotKeys<T> = T extends object
? {
[K in keyof T]: `${Exclude<K, symbol>}${DotKeys<T[K]> extends never
? ''
: `.${DotKeys<T[K]>}`}`;
}[keyof T]
: never;
export type GetDotKey<
T extends Record<string | number, any>,
K extends string
> = K extends `${infer U}.${infer Rest}` ? GetDotKey<T[U], Rest> : T[K]
K extends string,
> = K extends `${infer U}.${infer Rest}` ? GetDotKey<T[U], Rest> : T[K];
export interface PreferenceOptions {
location?: 'global' | 'project';
@ -25,8 +29,15 @@ export interface PreferenceOptions {
export type PreferenceKey = DotKeys<Preferences>;
export interface AstroPreferences {
get<Key extends PreferenceKey>(key: Key, opts?: PreferenceOptions): Promise<GetDotKey<Preferences, Key>>;
set<Key extends PreferenceKey>(key: Key, value: GetDotKey<Preferences, Key>, opts?: PreferenceOptions): Promise<void>;
get<Key extends PreferenceKey>(
key: Key,
opts?: PreferenceOptions
): Promise<GetDotKey<Preferences, Key>>;
set<Key extends PreferenceKey>(
key: Key,
value: GetDotKey<Preferences, Key>,
opts?: PreferenceOptions
): Promise<void>;
getAll(opts?: PreferenceOptions): Promise<Record<string, any>>;
}
@ -36,8 +47,10 @@ export function isValidKey(key: string): key is PreferenceKey {
export function coerce(key: string, value: unknown) {
const type = typeof dget(DEFAULT_PREFERENCES, key);
switch (type) {
case 'string': return value;
case 'number': return Number(value);
case 'string':
return value;
case 'number':
return Number(value);
case 'boolean': {
if (value === 'true' || value === 1) return true;
if (value === 'false' || value === 0) return false;
@ -60,13 +73,13 @@ export default function createPreferences(config: AstroConfig): AstroPreferences
stores[location].set(key, value);
},
async getAll({ location } = {}) {
if (!location) return Object.assign({}, stores['global'].getAll(), stores['project'].getAll());
if (!location)
return Object.assign({}, stores['global'].getAll(), stores['project'].getAll());
return stores[location].getAll();
},
}
};
}
// Adapted from https://github.com/sindresorhus/env-paths
export function getGlobalPreferenceDir() {
const name = 'astro';

View file

@ -6,7 +6,10 @@ import path from 'node:path';
export class PreferenceStore {
private file: string;
constructor(private dir: string, filename = 'settings.json') {
constructor(
private dir: string,
filename = 'settings.json'
) {
this.file = path.join(this.dir, filename);
}

View file

@ -18,9 +18,9 @@ export function createHighlight(rect: DOMRect, icon?: Icon) {
export function getHighlightZIndex(el: Element) {
let highestZIndex = 0;
let current: Element | ParentNode | null = el;
while(current instanceof Element) {
while (current instanceof Element) {
let zIndex = Number(getComputedStyle(current).zIndex);
if(!Number.isNaN(zIndex) && zIndex > highestZIndex) {
if (!Number.isNaN(zIndex) && zIndex > highestZIndex) {
highestZIndex = zIndex;
}
current = current.parentNode;

View file

@ -1,6 +1,11 @@
import type { DevOverlayMetadata, DevOverlayPlugin } from '../../../../@types/astro.js';
import type { DevOverlayHighlight } from '../ui-library/highlight.js';
import { attachTooltipToHighlight, createHighlight, getHighlightZIndex, positionHighlight } from './utils/highlight.js';
import {
attachTooltipToHighlight,
createHighlight,
getHighlightZIndex,
positionHighlight,
} from './utils/highlight.js';
const icon =
'<svg xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24"><path fill="#fff" d="M7.9 1.5v-.4a1.1 1.1 0 0 1 2.2 0v.4a1.1 1.1 0 1 1-2.2 0Zm-6.4 8.6a1.1 1.1 0 1 0 0-2.2h-.4a1.1 1.1 0 0 0 0 2.2h.4ZM12 3.7a1.1 1.1 0 0 0 1.4-.7l.4-1.1a1.1 1.1 0 0 0-2.1-.8l-.4 1.2a1.1 1.1 0 0 0 .7 1.4Zm-9.7 7.6-1.2.4a1.1 1.1 0 1 0 .8 2.1l1-.4a1.1 1.1 0 1 0-.6-2ZM20.8 17a1.9 1.9 0 0 1 0 2.6l-1.2 1.2a1.9 1.9 0 0 1-2.6 0l-4.3-4.2-1.6 3.6a1.9 1.9 0 0 1-1.7 1.2A1.9 1.9 0 0 1 7.5 20L2.7 5a1.9 1.9 0 0 1 2.4-2.4l15 5a1.9 1.9 0 0 1 .2 3.4l-3.7 1.6 4.2 4.3ZM19 18.3 14.6 14a1.9 1.9 0 0 1 .6-3l3.2-1.5L5.1 5.1l4.3 13.3 1.5-3.2a1.9 1.9 0 0 1 3-.6l4.4 4.4.7-.7Z"/></svg>';
@ -43,7 +48,7 @@ export default {
// Set the z-index to be 1 higher than the greatest z-index in the stack.
const zIndex = getHighlightZIndex(islandElement);
tooltip.style.zIndex = highlight.style.zIndex = zIndex+'';
tooltip.style.zIndex = highlight.style.zIndex = zIndex + '';
canvas.append(highlight);
islandsOverlays.push({ highlightElement: highlight, island: islandElement });

View file

@ -46,8 +46,6 @@ export class DevOverlayIcon extends HTMLElement {
fill: black;
}
}
</style>\n${this.getIconHTML(
this._icon
)}`;
</style>\n${this.getIconHTML(this._icon)}`;
}
}

View file

@ -2,7 +2,7 @@ import type http from 'node:http';
import type { ManifestData, SSRManifest } from '../@types/astro.js';
import { collectErrorMetadata } from '../core/errors/dev/index.js';
import { createSafeError } from '../core/errors/index.js';
import {formatErrorMessage} from '../core/messages.js';
import { formatErrorMessage } from '../core/messages.js';
import { collapseDuplicateSlashes, removeTrailingForwardSlash } from '../core/path.js';
import { eventError, telemetry } from '../events/index.js';
import { isServerLikeOutput } from '../prerender/utils.js';
@ -102,7 +102,10 @@ export async function handleRequest({
telemetry.record(eventError({ cmd: 'dev', err: errorWithMetadata, isFatal: false }));
pipeline.logger.error(null, formatErrorMessage(errorWithMetadata, pipeline.logger.level() === 'debug'));
pipeline.logger.error(
null,
formatErrorMessage(errorWithMetadata, pipeline.logger.level() === 'debug')
);
handle500Response(moduleLoader, incomingResponse, errorWithMetadata);
return err;

View file

@ -384,7 +384,10 @@ async function getScriptsAndStyles({ pipeline, filePath }: GetScriptsAndStylesPa
children: '',
});
if (settings.config.devOverlay.enabled && await settings.preferences.get('devOverlay.enabled')) {
if (
settings.config.devOverlay.enabled &&
(await settings.preferences.get('devOverlay.enabled'))
) {
scripts.add({
props: {
type: 'module',

View file

@ -1,5 +1,11 @@
# @astrojs/node
## 7.0.0-beta.1
### Major Changes
- [#9199](https://github.com/withastro/astro/pull/9199) [`49aa215a0`](https://github.com/withastro/astro/commit/49aa215a01ee1c4805316c85bb0aea6cfbc25a31) Thanks [@lilnasy](https://github.com/lilnasy)! - The internals of the integration have been updated to support Astro 4.0. Make sure to upgrade your Astro version as Astro 3.0 is no longer supported.
## 7.0.0-beta.0
### Patch Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/node",
"description": "Deploy your site to a Node.js server",
"version": "7.0.0-beta.0",
"version": "7.0.0-beta.1",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",

View file

@ -1,5 +1,11 @@
# @astrojs/vercel
## 6.0.0-beta.1
### Major Changes
- [#9199](https://github.com/withastro/astro/pull/9199) [`49aa215a0`](https://github.com/withastro/astro/commit/49aa215a01ee1c4805316c85bb0aea6cfbc25a31) Thanks [@lilnasy](https://github.com/lilnasy)! - The internals of the integration have been updated to support Astro 4.0. Make sure to upgrade your Astro version as Astro 3.0 is no longer supported.
## 6.0.0-beta.0
### Major Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/vercel",
"description": "Deploy your site to Vercel",
"version": "6.0.0-beta.0",
"version": "6.0.0-beta.1",
"type": "module",
"author": "withastro",
"license": "MIT",

View file

@ -125,7 +125,7 @@ importers:
examples/basics:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/blog:
@ -140,13 +140,13 @@ importers:
specifier: ^3.0.3
version: link:../../packages/integrations/sitemap
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/component:
devDependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/framework-alpine:
@ -161,7 +161,7 @@ importers:
specifier: ^3.13.3
version: 3.13.3
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/framework-lit:
@ -173,7 +173,7 @@ importers:
specifier: ^0.2.1
version: 0.2.1
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
lit:
specifier: ^2.8.0
@ -197,7 +197,7 @@ importers:
specifier: ^4.0.0-beta.0
version: link:../../packages/integrations/vue
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
preact:
specifier: ^10.19.2
@ -227,7 +227,7 @@ importers:
specifier: ^1.2.1
version: 1.2.1(preact@10.19.2)
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
preact:
specifier: ^10.19.2
@ -245,7 +245,7 @@ importers:
specifier: ^18.2.15
version: 18.2.15
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
react:
specifier: ^18.2.0
@ -260,7 +260,7 @@ importers:
specifier: ^3.0.2
version: link:../../packages/integrations/solid
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
solid-js:
specifier: ^1.8.5
@ -272,7 +272,7 @@ importers:
specifier: ^5.0.0-beta.0
version: link:../../packages/integrations/svelte
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
svelte:
specifier: ^4.2.5
@ -284,7 +284,7 @@ importers:
specifier: ^4.0.0-beta.0
version: link:../../packages/integrations/vue
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
vue:
specifier: ^3.3.8
@ -293,25 +293,25 @@ importers:
examples/hackernews:
dependencies:
'@astrojs/node':
specifier: ^7.0.0-beta.0
specifier: ^7.0.0-beta.1
version: link:../../packages/integrations/node
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/integration:
devDependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/middleware:
dependencies:
'@astrojs/node':
specifier: ^7.0.0-beta.0
specifier: ^7.0.0-beta.1
version: link:../../packages/integrations/node
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
html-minifier:
specifier: ^4.0.0
@ -320,31 +320,31 @@ importers:
examples/minimal:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/non-html-pages:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/portfolio:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/ssr:
dependencies:
'@astrojs/node':
specifier: ^7.0.0-beta.0
specifier: ^7.0.0-beta.1
version: link:../../packages/integrations/node
'@astrojs/svelte':
specifier: ^5.0.0-beta.0
version: link:../../packages/integrations/svelte
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
svelte:
specifier: ^4.2.5
@ -353,13 +353,13 @@ importers:
examples/view-transitions:
devDependencies:
'@astrojs/node':
specifier: ^7.0.0-beta.0
specifier: ^7.0.0-beta.1
version: link:../../packages/integrations/node
'@astrojs/tailwind':
specifier: ^6.0.0-beta.0
version: link:../../packages/integrations/tailwind
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/with-markdoc:
@ -368,7 +368,7 @@ importers:
specifier: ^1.0.0-beta.0
version: link:../../packages/integrations/markdoc
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/with-markdown-plugins:
@ -377,7 +377,7 @@ importers:
specifier: ^4.0.0-beta.0
version: link:../../packages/markdown/remark
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
hast-util-select:
specifier: ^6.0.2
@ -398,7 +398,7 @@ importers:
examples/with-markdown-shiki:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
examples/with-mdx:
@ -410,7 +410,7 @@ importers:
specifier: ^3.0.1
version: link:../../packages/integrations/preact
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
preact:
specifier: ^10.19.2
@ -425,7 +425,7 @@ importers:
specifier: ^0.5.0
version: 0.5.0(nanostores@0.9.5)(preact@10.19.2)
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
nanostores:
specifier: ^0.9.5
@ -446,7 +446,7 @@ importers:
specifier: ^1.6.3
version: 1.6.3
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
autoprefixer:
specifier: ^10.4.15
@ -464,7 +464,7 @@ importers:
examples/with-vite-plugin-pwa:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
vite-plugin-pwa:
specifier: 0.17.0
@ -476,7 +476,7 @@ importers:
examples/with-vitest:
dependencies:
astro:
specifier: ^4.0.0-beta.1
specifier: ^4.0.0-beta.2
version: link:../../packages/astro
vitest:
specifier: ^0.34.2