Merge branch 'withastro:main' into main

This commit is contained in:
Chris 2023-08-29 11:13:46 +02:00 committed by GitHub
commit 2e11ca5ea9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
77 changed files with 439 additions and 238 deletions

View file

@ -0,0 +1,6 @@
---
'@astrojs/telemetry': patch
'astro': patch
---
Update telemetry notice

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix, lazily initialize ResponseWithEncoding

View file

@ -34,6 +34,7 @@
"angry-dogs-shake",
"big-tips-whisper",
"brave-cheetahs-float",
"chatty-ways-hunt",
"chilled-ducks-grin",
"clever-bats-breathe",
"cool-feet-rest",
@ -52,6 +53,7 @@
"giant-plants-sip",
"gorgeous-kiwis-stare",
"grumpy-pens-melt",
"grumpy-years-remember",
"happy-penguins-hug",
"heavy-walls-arrive",
"honest-houses-deny",
@ -67,6 +69,7 @@
"neat-owls-run",
"neat-suns-search",
"odd-books-live",
"olive-moles-tan",
"perfect-horses-tell",
"plenty-keys-add",
"popular-carrots-sneeze",
@ -75,7 +78,9 @@
"quick-boats-bow",
"rude-ears-play",
"serious-waves-fry",
"shiny-dryers-swim",
"silent-bikes-crash",
"silly-dolphins-try",
"six-grapes-look",
"slimy-carrots-sell",
"small-nails-try",
@ -83,6 +88,7 @@
"spicy-eels-rush",
"spicy-icons-live",
"spicy-stingrays-cheer",
"strange-peas-agree",
"strong-papayas-chew",
"tame-files-glow",
"tasty-camels-speak",

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Paginate will now return exact types instead of a naive Record

View file

@ -0,0 +1,9 @@
---
'@astrojs/vercel': major
---
Vercel adapter now defaults to `functionPerRoute`.
With this change, `@astrojs/vercel/serverless` now splits each route into its own function. By doing this, the size of each function is reduced and startup time is faster.
You can disable this option, which will cause the code to be bundled into a single function, by setting `functionPerRoute` to `false`.

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Allow fallback animations on html element

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -14,6 +14,6 @@
"@astrojs/mdx": "^1.0.0-rc.2",
"@astrojs/rss": "^3.0.0-rc.2",
"@astrojs/sitemap": "^3.0.0-rc.1",
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -10,9 +10,9 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
},
"devDependencies": {
"@astrojs/deno": "^5.0.0-rc.1"
"@astrojs/deno": "^5.0.0-rc.2"
}
}

View file

@ -14,6 +14,6 @@
"@astrojs/alpinejs": "^0.3.0-rc.1",
"@types/alpinejs": "^3.7.2",
"alpinejs": "^3.12.3",
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/lit": "^3.0.0-rc.1",
"@webcomponents/template-shadowroot": "^0.2.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"lit": "^2.8.0"
}
}

View file

@ -16,7 +16,7 @@
"@astrojs/solid-js": "^3.0.0-rc.3",
"@astrojs/svelte": "^4.0.0-rc.2",
"@astrojs/vue": "^3.0.0-rc.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"preact": "^10.17.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.0.0-rc.2",
"@preact/signals": "^1.2.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"preact": "^10.17.1"
}
}

View file

@ -14,7 +14,7 @@
"@astrojs/react": "^3.0.0-rc.5",
"@types/react": "^18.2.21",
"@types/react-dom": "^18.2.7",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"react": "^18.2.0",
"react-dom": "^18.2.0"
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/solid-js": "^3.0.0-rc.3",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"solid-js": "^1.7.11"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/svelte": "^4.0.0-rc.2",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"svelte": "^4.2.0"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/vue": "^3.0.0-rc.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"vue": "^3.3.4"
}
}

View file

@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/node": "^6.0.0-rc.1",
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -15,7 +15,7 @@
],
"scripts": {},
"devDependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
},
"peerDependencies": {
"astro": "^2.0.0-beta.0"

View file

@ -13,7 +13,7 @@
},
"dependencies": {
"@astrojs/node": "^6.0.0-rc.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"html-minifier": "^4.0.0"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -14,7 +14,7 @@
"dependencies": {
"@astrojs/node": "^6.0.0-rc.1",
"@astrojs/svelte": "^4.0.0-rc.2",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"svelte": "^4.2.0"
}
}

View file

@ -12,6 +12,6 @@
},
"dependencies": {
"@astrojs/markdoc": "^0.5.0-rc.1",
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -12,7 +12,7 @@
},
"dependencies": {
"@astrojs/markdown-remark": "^3.0.0-rc.1",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"hast-util-select": "^5.0.5",
"rehype-autolink-headings": "^6.1.1",
"rehype-slug": "^5.1.0",

View file

@ -11,6 +11,6 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7"
"astro": "^3.0.0-rc.8"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/mdx": "^1.0.0-rc.2",
"@astrojs/preact": "^3.0.0-rc.2",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"preact": "^10.17.1"
}
}

View file

@ -13,7 +13,7 @@
"dependencies": {
"@astrojs/preact": "^3.0.0-rc.2",
"@nanostores/preact": "^0.5.0",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"nanostores": "^0.9.3",
"preact": "^10.17.1"
}

View file

@ -14,7 +14,7 @@
"@astrojs/mdx": "^1.0.0-rc.2",
"@astrojs/tailwind": "^5.0.0-rc.1",
"@types/canvas-confetti": "^1.6.0",
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"autoprefixer": "^10.4.15",
"canvas-confetti": "^1.6.0",
"postcss": "^8.4.28",

View file

@ -11,7 +11,7 @@
"astro": "astro"
},
"dependencies": {
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"vite-plugin-pwa": "0.16.4",
"workbox-window": "^7.0.0"
}

View file

@ -12,7 +12,7 @@
"test": "vitest"
},
"dependencies": {
"astro": "^3.0.0-rc.7",
"astro": "^3.0.0-rc.8",
"vitest": "^0.34.2"
}
}

View file

@ -1,5 +1,17 @@
# astro
## 3.0.0-rc.8
### Patch Changes
- [#8251](https://github.com/withastro/astro/pull/8251) [`46c4c0e05`](https://github.com/withastro/astro/commit/46c4c0e053f830585b9ef229ce1c259df00a80f8) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Adds a link to the error reference in the CLI when an error occurs
- [#8253](https://github.com/withastro/astro/pull/8253) [`1048aca55`](https://github.com/withastro/astro/commit/1048aca550769415e528016e42b358ffbfd44b61) Thanks [@matthewp](https://github.com/matthewp)! - Fix, lazily initialize ResponseWithEncoding
- [#8229](https://github.com/withastro/astro/pull/8229) [`ffc9e2d3d`](https://github.com/withastro/astro/commit/ffc9e2d3de46049bf3d82140ef018f524fb03187) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Paginate will now return exact types instead of a naive Record
- [#8237](https://github.com/withastro/astro/pull/8237) [`3674584e0`](https://github.com/withastro/astro/commit/3674584e02b161a698b429ceb66723918fdc56ac) Thanks [@Princesseuh](https://github.com/Princesseuh)! - Fix `astro check` not finding the `@astrojs/check` package
## 3.0.0-rc.7
### Patch Changes

View file

@ -57,7 +57,7 @@ declare module 'astro:assets' {
};
type WithRequired<T, K extends keyof T> = T & { [P in K]-?: T[P] };
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] };
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
type ImgAttributes = WithRequired<
Omit<import('./types').HTMLAttributes<'img'>, 'src' | 'width' | 'height'>,
'alt'

View file

@ -220,23 +220,15 @@ const { fallback = 'animate' } = Astro.props as Props;
links.length && (await Promise.all(links));
if (fallback === 'animate') {
let isAnimating = false;
addEventListener('animationstart', () => (isAnimating = true), { once: true });
// Trigger the animations
document.documentElement.dataset.astroTransitionFallback = 'old';
const finished = Promise.all(document.getAnimations().map(a => a.finished));
const fallbackSwap = () => {
removeEventListener('animationend', fallbackSwap);
clearTimeout(timeout);
swap();
document.documentElement.dataset.astroTransitionFallback = 'new';
};
// If there are any animations, want for the animationend event.
addEventListener('animationend', fallbackSwap, { once: true });
// If there are no animations, go ahead and swap on next tick
// This is necessary because we do not know if there are animations.
// The setTimeout is a fallback in case there are none.
let timeout = setTimeout(() => !isAnimating && fallbackSwap());
await finished;
fallbackSwap();
} else {
swap();
}

View file

@ -1,3 +1,3 @@
<video controls="" autoplay="" name="media" transition:persist transition:name="video">
<video controls="" autoplay="" name="media" transition:persist transition:name="video" autoplay>
<source src="https://ia804502.us.archive.org/33/items/GoldenGa1939_3/GoldenGa1939_3_512kb.mp4" type="video/mp4">
</video>

View file

@ -6,12 +6,4 @@ import Video from '../components/Video.astro';
<p id="video-one">Page 1</p>
<a id="click-two" href="/video-two">go to 2</a>
<Video />
<script>
const vid = document.querySelector('video');
vid.addEventListener('canplay', () => {
// Jump to the 1 minute mark
vid.currentTime = 60;
vid.dataset.ready = '';
}, { once: true });
</script>
</Layout>

View file

@ -302,7 +302,7 @@ test.describe('View Transitions', () => {
// Go to page 1
await page.goto(astro.resolveUrl('/video-one'));
const vid = page.locator('video[data-ready]');
const vid = page.locator('video');
await expect(vid).toBeVisible();
const firstTime = await page.evaluate(getTime);

View file

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

View file

@ -24,6 +24,8 @@ import type { AstroIntegrationLogger, Logger, LoggerLevel } from '../core/logger
import type { AstroComponentFactory, AstroComponentInstance } from '../runtime/server';
import type { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from './../core/constants.js';
export { type AstroIntegrationLogger };
export type {
MarkdownHeading,
MarkdownMetadata,
@ -1600,7 +1602,9 @@ export type GetStaticPaths = (
* const { slug } = Astro.params as Params;
* ```
*/
export type InferGetStaticParamsType<T> = T extends () => infer R | Promise<infer R>
export type InferGetStaticParamsType<T> = T extends (
opts?: GetStaticPathsOptions
) => infer R | Promise<infer R>
? R extends Array<infer U>
? U extends { params: infer P }
? P
@ -1631,7 +1635,9 @@ export type InferGetStaticParamsType<T> = T extends () => infer R | Promise<infe
* const { propA, propB } = Astro.props;
* ```
*/
export type InferGetStaticPropsType<T> = T extends () => infer R | Promise<infer R>
export type InferGetStaticPropsType<T> = T extends (
opts: GetStaticPathsOptions
) => infer R | Promise<infer R>
? R extends Array<infer U>
? U extends { props: infer P }
? P
@ -1678,13 +1684,13 @@ export type MarkdownContent<T extends Record<string, any> = Record<string, any>>
*
* [Astro reference](https://docs.astro.build/en/reference/api-reference/#paginate)
*/
export interface PaginateOptions {
export interface PaginateOptions<PaginateProps extends Props, PaginateParams extends Params> {
/** the number of items per-page (default: `10`) */
pageSize?: number;
/** key: value object of page params (ex: `{ tag: 'javascript' }`) */
params?: Params;
params?: PaginateParams;
/** object of props to forward to `page` result */
props?: Props;
props?: PaginateProps;
}
/**
@ -1718,7 +1724,33 @@ export interface Page<T = any> {
};
}
export type PaginateFunction = (data: any[], args?: PaginateOptions) => GetStaticPathsResult;
type OmitIndexSignature<ObjectType> = {
// eslint-disable-next-line @typescript-eslint/ban-types
[KeyType in keyof ObjectType as {} extends Record<KeyType, unknown>
? never
: KeyType]: ObjectType[KeyType];
};
// eslint-disable-next-line @typescript-eslint/ban-types
type Simplify<T> = { [KeyType in keyof T]: T[KeyType] } & {};
export type PaginateFunction = <
PaginateData,
AdditionalPaginateProps extends Props,
AdditionalPaginateParams extends Params,
>(
data: PaginateData[],
args?: PaginateOptions<AdditionalPaginateProps, AdditionalPaginateParams>
) => {
params: Simplify<
{
page: string | undefined;
} & OmitIndexSignature<AdditionalPaginateParams>
>;
props: Simplify<
{
page: Page<PaginateData>;
} & OmitIndexSignature<AdditionalPaginateProps>
>;
}[];
export type Params = Record<string, string | undefined>;
@ -2173,6 +2205,7 @@ export interface PreviewServerParams {
host: string | undefined;
port: number;
base: string;
logger: AstroIntegrationLogger;
}
export type CreatePreviewServer = (

View file

@ -109,6 +109,11 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
await update(subcommand, { flags });
return;
}
case 'sync': {
const { sync } = await import('./sync/index.js');
const exitCode = await sync({ flags });
return process.exit(exitCode);
}
}
// In verbose/debug mode, we log the debug logs asap before any potential errors could appear
@ -122,6 +127,9 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
process.env.NODE_ENV = cmd === 'dev' ? 'development' : 'production';
}
const { notify } = await import('./telemetry/index.js');
await notify();
// These commands uses the logging and user config. All commands are assumed to have been handled
// by the end of this switch statement.
switch (cmd) {
@ -161,11 +169,6 @@ async function runCommand(cmd: string, flags: yargs.Arguments) {
return process.exit(checkServer ? 1 : 0);
}
}
case 'sync': {
const { sync } = await import('./sync/index.js');
const exitCode = await sync({ flags });
return process.exit(exitCode);
}
}
// No command handler matched! This is unexpected.

View file

@ -7,6 +7,13 @@ interface TelemetryOptions {
flags: yargs.Arguments;
}
export async function notify() {
await telemetry.notify(() => {
console.log(msg.telemetryNotice() + '\n');
return true;
});
}
export async function update(subcommand: string, { flags }: TelemetryOptions) {
const isValid = ['enable', 'disable', 'reset'].includes(subcommand);

View file

@ -9,7 +9,7 @@ import type {
import type { SinglePageBuiltModule } from '../build/types';
import { getSetCookiesFromResponse } from '../cookies/index.js';
import { consoleLogDestination } from '../logger/console.js';
import { Logger } from '../logger/core.js';
import { AstroIntegrationLogger, Logger } from '../logger/core.js';
import {
collapseDuplicateSlashes,
prependForwardSlash,
@ -58,6 +58,7 @@ export class App {
#pipeline: SSRRoutePipeline;
#onRequest: MiddlewareEndpointHandler | undefined;
#middlewareLoaded: boolean;
#adapterLogger: AstroIntegrationLogger;
constructor(manifest: SSRManifest, streaming = true) {
this.#manifest = manifest;
@ -68,10 +69,14 @@ export class App {
this.#baseWithoutTrailingSlash = removeTrailingForwardSlash(this.#manifest.base);
this.#pipeline = new SSRRoutePipeline(this.#createEnvironment(streaming));
this.#middlewareLoaded = false;
this.#adapterLogger = new AstroIntegrationLogger(
this.#logger.options,
this.#manifest.adapterName
);
}
set setManifest(newManifest: SSRManifest) {
this.#manifest = newManifest;
getAdapterLogger(): AstroIntegrationLogger {
return this.#adapterLogger;
}
/**

View file

@ -163,7 +163,7 @@ export async function generatePages(opts: StaticBuildOptions, internals: BuildIn
opts.settings.adapter?.adapterFeatures?.functionPerRoute
) {
// forcing to use undefined, so we fail in an expected way if the module is not even there.
const ssrEntry = ssrEntryPage?.manifest?.pageModule;
const ssrEntry = ssrEntryPage?.pageModule;
if (ssrEntry) {
await generatePage(pageData, ssrEntry, builtPaths, pipeline);
} else {

View file

@ -178,6 +178,8 @@ function vitePluginSSRSplit(
imports.push(...ssrCode.imports);
contents.push(...ssrCode.contents);
exports.push('export { pageModule }');
return `${imports.join('\n')}${contents.join('\n')}${exports.join('\n')}`;
}
return void 0;

View file

@ -39,6 +39,7 @@ export function createAPIContext({
props,
adapterName,
}: CreateAPIContext): APIContext {
initResponseWithEncoding();
const context = {
cookies: new AstroCookies(request),
request,
@ -91,28 +92,44 @@ export function createAPIContext({
type ResponseParameters = ConstructorParameters<typeof Response>;
export class ResponseWithEncoding extends Response {
constructor(body: ResponseParameters[0], init: ResponseParameters[1], encoding?: BufferEncoding) {
// If a body string is given, try to encode it to preserve the behaviour as simple objects.
// We don't do the full handling as simple objects so users can control how headers are set instead.
if (typeof body === 'string') {
// In NodeJS, we can use Buffer.from which supports all BufferEncoding
if (typeof Buffer !== 'undefined' && Buffer.from) {
body = Buffer.from(body, encoding);
export let ResponseWithEncoding: ReturnType<typeof initResponseWithEncoding>;
// TODO Remove this after StackBlitz supports Node 18.
let initResponseWithEncoding = () => {
class LocalResponseWithEncoding extends Response {
constructor(
body: ResponseParameters[0],
init: ResponseParameters[1],
encoding?: BufferEncoding
) {
// If a body string is given, try to encode it to preserve the behaviour as simple objects.
// We don't do the full handling as simple objects so users can control how headers are set instead.
if (typeof body === 'string') {
// In NodeJS, we can use Buffer.from which supports all BufferEncoding
if (typeof Buffer !== 'undefined' && Buffer.from) {
body = Buffer.from(body, encoding);
}
// In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
body = encoder.encode(body);
}
}
// In non-NodeJS, use the web-standard TextEncoder for utf-8 strings
else if (encoding == null || encoding === 'utf8' || encoding === 'utf-8') {
body = encoder.encode(body);
super(body, init);
if (encoding) {
this.headers.set('X-Astro-Encoding', encoding);
}
}
super(body, init);
if (encoding) {
this.headers.set('X-Astro-Encoding', encoding);
}
}
}
// Set the module scoped variable.
ResponseWithEncoding = LocalResponseWithEncoding;
// Turn this into a noop.
initResponseWithEncoding = (() => {}) as any;
return LocalResponseWithEncoding;
};
export async function callEndpoint<MiddlewareResult = Response | EndpointOutput>(
mod: EndpointHandler,

View file

@ -1,4 +1,3 @@
import boxen from 'boxen';
import {
bgCyan,
bgGreen,
@ -107,34 +106,29 @@ export function serverStart({
}
export function telemetryNotice() {
const headline = yellow(`Astro now collects ${bold('anonymous')} usage data.`);
const why = `This ${bold('optional program')} will help shape our roadmap.`;
const more = `For more info, visit ${underline('https://astro.build/telemetry')}`;
const box = boxen([headline, why, '', more].join('\n'), {
margin: 0,
padding: 1,
borderStyle: 'round',
borderColor: 'yellow',
});
return box;
const headline = `${cyan('◆')} Astro collects completely anonymous usage data.`;
const why = dim(' This optional program helps shape our roadmap.');
const disable = dim(' Run `npm run astro telemetry disable` to opt-out.');
const details = ` Details: ${underline('https://astro.build/telemetry')}`;
return [headline, why, disable, details].map((v) => ' ' + v).join('\n');
}
export function telemetryEnabled() {
return `\n ${green('◉')} Anonymous telemetry is ${bgGreen(
black(' enabled ')
)}. Thank you for improving Astro!\n`;
return `${green('◉')} Anonymous telemetry is now ${bgGreen(black(' enabled '))}\n ${dim(
'Thank you for improving Astro!'
)}\n`;
}
export function telemetryDisabled() {
return `\n ${yellow('◯')} Anonymous telemetry is ${bgYellow(
black(' disabled ')
)}. We won't share any usage data.\n`;
return `${yellow('◯')} Anonymous telemetry is now ${bgYellow(black(' disabled '))}\n ${dim(
"We won't ever record your usage data."
)}\n`;
}
export function telemetryReset() {
return `\n ${cyan('◆')} Anonymous telemetry has been ${bgCyan(
black(' reset ')
)}. You may be prompted again.\n`;
return `${cyan('◆')} Anonymous telemetry has been ${bgCyan(black(' reset '))}\n ${dim(
'You may be prompted again.'
)}\n`;
}
export function fsStrictWarning() {

View file

@ -1,6 +1,7 @@
import { createRequire } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroInlineConfig, PreviewModule, PreviewServer } from '../../@types/astro';
import { AstroIntegrationLogger } from '../../core/logger/core.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/index.js';
@ -62,6 +63,7 @@ export default async function preview(inlineConfig: AstroInlineConfig): Promise<
host: getResolvedHostForHttpServer(settings.config.server.host),
port: settings.config.server.port,
base: settings.config.base,
logger: new AstroIntegrationLogger(logger.options, settings.adapter.name),
});
return server;

View file

@ -1,18 +1,20 @@
import type {
GetStaticPathsResult,
Page,
PaginateFunction,
PaginateOptions,
Params,
Props,
RouteData,
} from '../../@types/astro';
import { AstroError, AstroErrorData } from '../errors/index.js';
export function generatePaginateFunction(routeMatch: RouteData): PaginateFunction {
export function generatePaginateFunction(
routeMatch: RouteData
): (...args: Parameters<PaginateFunction>) => ReturnType<PaginateFunction> {
return function paginateUtility(
data: any[],
args: { pageSize?: number; params?: Params; props?: Props } = {}
) {
args: PaginateOptions<Props, Params> = {}
): ReturnType<PaginateFunction> {
let { pageSize: _pageSize, params: _params, props: _props } = args;
const pageSize = _pageSize || 10;
const paramName = 'page';
@ -31,7 +33,7 @@ export function generatePaginateFunction(routeMatch: RouteData): PaginateFunctio
}
const lastPage = Math.max(1, Math.ceil(data.length / pageSize));
const result: GetStaticPathsResult = [...Array(lastPage).keys()].map((num) => {
const result = [...Array(lastPage).keys()].map((num) => {
const pageNum = num + 1;
const start = pageSize === Infinity ? 0 : (pageNum - 1) * pageSize; // currentPage is 1-indexed
const end = Math.min(start + pageSize, data.length);

View file

@ -3,6 +3,7 @@ import type {
GetStaticPathsItem,
GetStaticPathsResult,
GetStaticPathsResultKeyed,
PaginateFunction,
Params,
RouteData,
RuntimeMode,
@ -50,7 +51,9 @@ export async function callGetStaticPaths({
// Calculate your static paths.
let staticPaths: GetStaticPathsResult = [];
staticPaths = await mod.getStaticPaths({
paginate: generatePaginateFunction(route),
// Q: Why the cast?
// A: So users downstream can have nicer typings, we have to make some sacrifice in our internal typings, which necessitate a cast here
paginate: generatePaginateFunction(route) as PaginateFunction,
rss() {
throw new AstroError(AstroErrorData.GetStaticPathsRemovedRSSHelper);
},

View file

@ -52,7 +52,8 @@ export function renderTransition(
}
}
} else if (animationName === 'none') {
sheet.addAnimationRaw('old', 'animation: none; opacity: 0; mix-blend-mode: normal;');
sheet.addFallback('old', 'animation: none; mix-blend-mode: normal;');
sheet.addModern('old', 'animation: none; opacity: 0; mix-blend-mode: normal;');
sheet.addAnimationRaw('new', 'animation: none; mix-blend-mode: normal;');
}
@ -88,11 +89,22 @@ class ViewTransitionStyleSheet {
}
addAnimationRaw(image: 'old' | 'new' | 'group', animation: string) {
const { scope, name } = this;
this.addModern(image, animation);
this.addFallback(image, animation);
}
addModern(image: 'old' | 'new' | 'group', animation: string) {
const { name } = this;
this.addRule('modern', `::view-transition-${image}(${name}) { ${animation} }`);
}
addFallback(image: 'old' | 'new' | 'group', animation: string) {
const { scope } = this;
this.addRule(
'fallback',
`[data-astro-transition-fallback="${image}"] [data-astro-transition-scope="${scope}"] { ${animation} }`
// Two selectors here, the second in case there is an animation on the root.
`[data-astro-transition-fallback="${image}"] [data-astro-transition-scope="${scope}"],
[data-astro-transition-fallback="${image}"][data-astro-transition-scope="${scope}"] { ${animation} }`
);
}
@ -107,7 +119,8 @@ class ViewTransitionStyleSheet {
this.addRule('modern', `${prefix}::view-transition-${image}(${name}) { ${animation} }`);
this.addRule(
'fallback',
`${prefix}[data-astro-transition-fallback="${image}"] [data-astro-transition-scope="${scope}"] { ${animation} }`
`${prefix}[data-astro-transition-fallback="${image}"] [data-astro-transition-scope="${scope}"],
${prefix}[data-astro-transition-fallback="${image}"][data-astro-transition-scope="${scope}"] { ${animation} }`
);
}
}

View file

@ -45,7 +45,7 @@
"tiny-glob": "^0.2.9"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -1,45 +0,0 @@
// TODO: remove `getRuntime()` in Astro 3.0
import type { Cache, CacheStorage, IncomingRequestCfProperties } from '@cloudflare/workers-types';
export type WorkerRuntime<T = unknown> = {
name: 'cloudflare';
env: T;
waitUntil(promise: Promise<any>): void;
passThroughOnException(): void;
caches?: CacheStorage & { default: Cache };
cf?: IncomingRequestCfProperties;
};
export type PagesRuntime<T = unknown, U = unknown> = {
name: 'cloudflare';
env: T;
functionPath: string;
params: Record<string, string>;
data: U;
waitUntil(promise: Promise<any>): void;
next(request: Request): void;
caches?: CacheStorage & { default: Cache };
cf?: IncomingRequestCfProperties;
};
/**
* @deprecated since version 6.8.0
* The `getRuntime` utility has been deprecated and should be updated to the new [`Astro.locals`](https://docs.astro.build/en/guides/middleware/#locals) API.
* ```diff
* - import { getRuntime } from '@astrojs/cloudflare/runtime';
* - getRuntime(Astro.request);
*
* + const runtime = Astro.locals.runtime;
* ```
*/
export function getRuntime<T = unknown, U = unknown>(
request: Request
): WorkerRuntime<T> | PagesRuntime<T, U> {
if (!!request) {
return Reflect.get(request, Symbol.for('runtime'));
} else {
throw new Error(
'To retrieve the current cloudflare runtime you need to pass in the Astro request object'
);
}
}

View file

@ -1,6 +1,5 @@
---
import { getRuntime } from '@astrojs/cloudflare/runtime';
const runtime = getRuntime(Astro.request);
const runtime = Astro.locals.runtime;
---
<html>
<head>

View file

@ -1,5 +1,14 @@
# @astrojs/deno
## 5.0.0-rc.2
### Patch Changes
- [#8245](https://github.com/withastro/astro/pull/8245) [`ed39fbf16`](https://github.com/withastro/astro/commit/ed39fbf168f7a30c4fbf5b5618b70146ce5d5b3e) Thanks [@florian-lefebvre](https://github.com/florian-lefebvre)! - TypeScript users now get better suggestions when configuring the Deno adapter.
- Updated dependencies [[`46c4c0e05`](https://github.com/withastro/astro/commit/46c4c0e053f830585b9ef229ce1c259df00a80f8), [`1048aca55`](https://github.com/withastro/astro/commit/1048aca550769415e528016e42b358ffbfd44b61), [`ffc9e2d3d`](https://github.com/withastro/astro/commit/ffc9e2d3de46049bf3d82140ef018f524fb03187), [`3674584e0`](https://github.com/withastro/astro/commit/3674584e02b161a698b429ceb66723918fdc56ac)]:
- astro@3.0.0-rc.8
## 5.0.0-rc.1
### Major Changes

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/deno",
"description": "Deploy your site to a Deno server",
"version": "5.0.0-rc.1",
"version": "5.0.0-rc.2",
"type": "module",
"types": "./dist/index.d.ts",
"author": "withastro",
@ -36,7 +36,7 @@
"esbuild": "^0.19.2"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"astro": "workspace:*",

View file

@ -75,7 +75,7 @@
"zod": "3.21.1"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"@astrojs/markdown-remark": "workspace:*",

View file

@ -54,7 +54,7 @@
"vfile": "^5.3.7"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"@types/chai": "^4.3.5",

View file

@ -43,7 +43,7 @@
"esbuild": "^0.19.2"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"@netlify/edge-functions": "^2.0.0",

View file

@ -37,7 +37,7 @@
"server-destroy": "^1.0.1"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"@types/node": "^18.17.8",

View file

@ -1,6 +1,6 @@
import type { AstroAdapter, AstroIntegration } from 'astro';
import { AstroError } from 'astro/errors';
import type { Options, UserOptions } from './types';
export function getAdapter(options: Options): AstroAdapter {
return {
name: '@astrojs/node',
@ -23,7 +23,7 @@ export function getAdapter(options: Options): AstroAdapter {
export default function createIntegration(userOptions: UserOptions): AstroIntegration {
if (!userOptions?.mode) {
throw new Error(`[@astrojs/node] Setting the 'mode' option is required.`);
throw new AstroError(`Setting the 'mode' option is required.`);
}
let _options: Options;

View file

@ -1,4 +1,5 @@
import type { CreatePreviewServer } from 'astro';
import { AstroError } from 'astro/errors';
import type http from 'node:http';
import { fileURLToPath } from 'node:url';
import { getNetworkAddress } from './get-network-address.js';
@ -11,6 +12,7 @@ const preview: CreatePreviewServer = async function ({
host,
port,
base,
logger,
}) {
type ServerModule = ReturnType<typeof createExports>;
type MaybeServerModule = Partial<ServerModule>;
@ -21,13 +23,13 @@ const preview: CreatePreviewServer = async function ({
if (typeof ssrModule.handler === 'function') {
ssrHandler = ssrModule.handler;
} else {
throw new Error(
throw new AstroError(
`The server entrypoint doesn't have a handler. Are you sure this is the right file?`
);
}
} catch (err) {
if ((err as any).code === 'ERR_MODULE_NOT_FOUND') {
throw new Error(
throw new AstroError(
`The server entrypoint ${fileURLToPath(
serverEntrypoint
)} does not exist. Have you ran a build yet?`
@ -63,13 +65,11 @@ const preview: CreatePreviewServer = async function ({
const address = getNetworkAddress('http', host, port);
if (host === undefined) {
// eslint-disable-next-line no-console
console.log(
logger.info(
`Preview server listening on \n local: ${address.local[0]} \t\n network: ${address.network[0]}\n`
);
} else {
// eslint-disable-next-line no-console
console.log(`Preview server listening on ${address.local[0]}`);
logger.info(`Preview server listening on ${address.local[0]}`);
}
return server;

View file

@ -4,6 +4,7 @@
* - https://github.com/apollographql/apollo-client/blob/main/src/utilities/common/responseIterator.ts
*/
import { AstroError } from 'astro/errors';
import type { ReadableStreamDefaultReadResult } from 'node:stream/web';
import { Readable as NodeReadableStream } from 'stream';
@ -221,5 +222,7 @@ export function responseIterator<T>(response: Response | Buffer): AsyncIterableI
if (isNodeReadableStream(body)) return nodeStreamIterator<T>(body);
throw new Error('Unknown body type for responseIterator. Please pass a streamable response.');
throw new AstroError(
'Unknown body type for responseIterator. Please pass a streamable response.'
);
}

View file

@ -37,6 +37,7 @@ export function getResolvedHostForHttpServer(host: string | boolean) {
}
export default function startServer(app: NodeApp, options: Options) {
const logger = app.getAdapterLogger();
const port = process.env.PORT ? Number(process.env.PORT) : options.port ?? 8080;
const { client } = resolvePaths(options);
const handler = middleware(app, options.mode);
@ -59,13 +60,11 @@ export default function startServer(app: NodeApp, options: Options) {
const address = getNetworkAddress(protocol, host, port);
if (host === undefined) {
// eslint-disable-next-line no-console
console.log(
`Preview server listening on \n local: ${address.local[0]} \t\n network: ${address.network[0]}\n`
logger.info(
`Server listening on \n local: ${address.local[0]} \t\n network: ${address.network[0]}\n`
);
} else {
// eslint-disable-next-line no-console
console.log(`Preview server listening on ${address.local[0]}`);
logger.info(`Server listening on ${address.local[0]}`);
}
return {

View file

@ -48,7 +48,7 @@
"vite": "^4.4.9"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7",
"astro": "workspace:^3.0.0-rc.8",
"svelte": "^3.55.0 || ^4.0.0"
},
"engines": {

View file

@ -43,7 +43,7 @@
"vite": "^4.4.9"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7",
"astro": "workspace:^3.0.0-rc.8",
"tailwindcss": "^3.0.24"
}
}

View file

@ -1,5 +1,20 @@
# @astrojs/vercel
## 4.0.0-rc.5
### Major Changes
- [#8239](https://github.com/withastro/astro/pull/8239) [`52f0837bd`](https://github.com/withastro/astro/commit/52f0837bdeca0b54e07cbf76a7570bd042b98922) Thanks [@matthewp](https://github.com/matthewp)! - Vercel adapter now defaults to `functionPerRoute`.
With this change, `@astrojs/vercel/serverless` now splits each route into its own function. By doing this, the size of each function is reduced and startup time is faster.
You can disable this option, which will cause the code to be bundled into a single function, by setting `functionPerRoute` to `false`.
### Patch Changes
- Updated dependencies [[`46c4c0e05`](https://github.com/withastro/astro/commit/46c4c0e053f830585b9ef229ce1c259df00a80f8), [`1048aca55`](https://github.com/withastro/astro/commit/1048aca550769415e528016e42b358ffbfd44b61), [`ffc9e2d3d`](https://github.com/withastro/astro/commit/ffc9e2d3de46049bf3d82140ef018f524fb03187), [`3674584e0`](https://github.com/withastro/astro/commit/3674584e02b161a698b429ceb66723918fdc56ac)]:
- astro@3.0.0-rc.8
## 4.0.0-rc.4
### Major Changes

View file

@ -244,9 +244,11 @@ export default defineConfig({
});
```
### Per-page functions
### Function bundling configuration
The Vercel adapter builds to a single function by default. Astro 2.7 added support for splitting your build into separate entry points per page. If you use this configuration the Vercel adapter will generate a separate function for each page. This can help reduce the size of each function so they are only bundling code used on that page.
The Vercel adapter splits builds into a separate function per route by default. This helps reduce the size of each function, as it only bundles code used on that page.
You can disable this and build to a single function by setting the `functionPerRoute` configuration option to `false`:
```js
// astro.config.mjs
@ -256,7 +258,7 @@ import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercel({
functionPerRoute: true,
functionPerRoute: false,
}),
});
```

View file

@ -1,7 +1,7 @@
{
"name": "@astrojs/vercel",
"description": "Deploy your site to Vercel",
"version": "4.0.0-rc.4",
"version": "4.0.0-rc.5",
"type": "module",
"author": "withastro",
"license": "MIT",
@ -17,8 +17,8 @@
"bugs": "https://github.com/withastro/astro/issues",
"homepage": "https://docs.astro.build/en/guides/integrations-guide/vercel/",
"exports": {
"./edge": "./dist/edge/adapter.js",
"./edge/entrypoint": "./dist/edge/entrypoint.js",
"./edge": "./dist/edge/throw.js",
"./edge/entrypoint": "./dist/edge/throw.js",
"./serverless": "./dist/serverless/adapter.js",
"./serverless/entrypoint": "./dist/serverless/entrypoint.js",
"./static": "./dist/static/adapter.js",
@ -60,7 +60,7 @@
"web-vitals": "^3.4.0"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7"
"astro": "workspace:^3.0.0-rc.8"
},
"devDependencies": {
"@types/set-cookie-parser": "^2.4.3",

View file

@ -0,0 +1,18 @@
const msg = `
The Astro Vercel Edge adapter has been removed. We recommend switching to @astrojs/vercel/serverless and enabling Edge middleware.
import { defineConfig } from 'astro/config';
import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
output: 'server',
adapter: vercel({
edgeMiddleware: true,
})
})
`.trim();
throw new Error(msg);
// Make sure bundlers treat this as ESM.
export default {};

View file

@ -1,5 +1,5 @@
import type { AstroAdapter, AstroConfig, AstroIntegration, RouteData } from 'astro';
import { AstroError } from 'astro/errors';
import glob from 'fast-glob';
import { basename } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
@ -77,7 +77,7 @@ export default function vercelServerless({
excludeFiles,
imageService,
imagesConfig,
functionPerRoute = false,
functionPerRoute = true,
edgeMiddleware = false,
}: VercelServerlessConfig = {}): AstroIntegration {
let _config: AstroConfig;
@ -153,10 +153,9 @@ export default function vercelServerless({
serverEntry = config.build.serverEntry;
if (config.output === 'static') {
throw new Error(`
[@astrojs/vercel] \`output: "server"\` or \`output: "hybrid"\` is required to use the serverless adapter.
`);
throw new AstroError(
'`output: "server"` or `output: "hybrid"` is required to use the serverless adapter.'
);
}
},

View file

@ -4,7 +4,7 @@ import vercel from '@astrojs/vercel/serverless';
export default defineConfig({
adapter: vercel({
// Pass some value to make sure it doesn't error out
includeFiles: ['included.js']
includeFiles: ['included.js'],
}),
output: 'server'
});

View file

@ -56,7 +56,7 @@
"vue": "^3.3.4"
},
"peerDependencies": {
"astro": "workspace:^3.0.0-rc.7",
"astro": "workspace:^3.0.0-rc.8",
"vue": "^3.2.30"
},
"engines": {

View file

@ -10,6 +10,9 @@ import { getSystemInfo, type SystemInfo } from './system-info.js';
export type AstroTelemetryOptions = { astroVersion: string; viteVersion: string };
export type TelemetryEvent = { eventName: string; payload: Record<string, any> };
// In the event of significant policy changes, update this!
const VALID_TELEMETRY_NOTICE_DATE = '2023-08-25';
type EventMeta = SystemInfo;
interface EventContext extends ProjectInfo {
anonymousId: string;
@ -20,6 +23,8 @@ export class AstroTelemetry {
private _anonymousProjectInfo: ProjectInfo | undefined;
private config = new GlobalConfig({ name: 'astro' });
private debug = debug('astro:telemetry');
private isCI = isCI;
private env = process.env;
private get astroVersion() {
return this.opts.astroVersion;
@ -28,10 +33,10 @@ export class AstroTelemetry {
return this.opts.viteVersion;
}
private get ASTRO_TELEMETRY_DISABLED() {
return process.env.ASTRO_TELEMETRY_DISABLED;
return this.env.ASTRO_TELEMETRY_DISABLED;
}
private get TELEMETRY_DISABLED() {
return process.env.TELEMETRY_DISABLED;
return this.env.TELEMETRY_DISABLED;
}
constructor(private opts: AstroTelemetryOptions) {
@ -47,7 +52,7 @@ export class AstroTelemetry {
*/
private getConfigWithFallback<T>(key: string, getValue: () => T): T {
const currentValue = this.config.get(key);
if (currentValue) {
if (currentValue !== undefined) {
return currentValue;
}
const newValue = getValue();
@ -75,7 +80,7 @@ export class AstroTelemetry {
private get anonymousProjectInfo(): ProjectInfo {
// NOTE(fks): this value isn't global, so it can't use getConfigWithFallback().
this._anonymousProjectInfo = this._anonymousProjectInfo || getProjectInfo(isCI);
this._anonymousProjectInfo = this._anonymousProjectInfo || getProjectInfo(this.isCI);
return this._anonymousProjectInfo;
}
@ -94,19 +99,29 @@ export class AstroTelemetry {
return this.config.clear();
}
async notify(callback: () => Promise<boolean>) {
if (this.isDisabled || isCI) {
isValidNotice() {
if (!this.notifyDate) return false;
const current = Number(this.notifyDate);
const valid = new Date(VALID_TELEMETRY_NOTICE_DATE).valueOf();
return current > valid;
}
async notify(callback: () => boolean | Promise<boolean>) {
if (this.isDisabled || this.isCI) {
this.debug(`[notify] telemetry has been disabled`);
return;
}
// The end-user has already been notified about our telemetry integration!
// Don't bother them about it again.
// In the event of significant changes, we should invalidate old dates.
if (this.notifyDate) {
if (this.isValidNotice()) {
this.debug(`[notify] last notified on ${this.notifyDate}`);
return;
}
const enabled = await callback();
this.config.set(KEY.TELEMETRY_NOTIFY_DATE, Date.now().toString());
this.config.set(KEY.TELEMETRY_NOTIFY_DATE, new Date().valueOf().toString());
this.config.set(KEY.TELEMETRY_ENABLED, enabled);
this.debug(`[notify] telemetry has been ${enabled ? 'enabled' : 'disabled'}`);
}
async record(event: TelemetryEvent | TelemetryEvent[] = []) {
@ -117,7 +132,7 @@ export class AstroTelemetry {
// Skip recording telemetry if the feature is disabled
if (this.isDisabled) {
this.debug('telemetry disabled');
this.debug('[record] telemetry has been disabled');
return Promise.resolve();
}

View file

@ -1,9 +1,83 @@
import { expect } from 'chai';
import { AstroTelemetry } from '../dist/index.js';
function setup() {
const config = new Map();
const telemetry = new AstroTelemetry({ version: '0.0.0-test.1' });
const logs = [];
// Stub isCI to false so we can test user-facing behavior
telemetry.isCI = false;
// Stub process.env to properly test in Astro's own CI
telemetry.env = {};
// Override config so we can inspect it
telemetry.config = config;
// Override debug so we can inspect it
telemetry.debug.enabled = true;
telemetry.debug.log = (...args) => logs.push(args);
return { telemetry, config, logs };
}
describe('AstroTelemetry', () => {
let oldCI;
before(() => {
oldCI = process.env.CI;
// Stub process.env.CI to `false`
process.env.CI = 'false';
});
after(() => {
process.env.CI = oldCI;
});
it('initializes when expected arguments are given', () => {
const telemetry = new AstroTelemetry({ version: '0.0.0-test.1' });
const { telemetry } = setup();
expect(telemetry).to.be.instanceOf(AstroTelemetry);
});
it('does not record event if disabled', async () => {
const { telemetry, config, logs } = setup();
telemetry.setEnabled(false);
const [key] = Array.from(config.keys());
expect(key).not.to.be.undefined;
expect(config.get(key)).to.be.false;
expect(telemetry.enabled).to.be.false;
expect(telemetry.isDisabled).to.be.true;
const result = await telemetry.record(['TEST']);
expect(result).to.be.undefined;
const [log] = logs;
expect(log).not.to.be.undefined;
expect(logs.join('')).to.match(/disabled/);
});
it('records event if enabled', async () => {
const { telemetry, config, logs } = setup();
telemetry.setEnabled(true);
const [key] = Array.from(config.keys());
expect(key).not.to.be.undefined;
expect(config.get(key)).to.be.true;
expect(telemetry.enabled).to.be.true;
expect(telemetry.isDisabled).to.be.false;
await telemetry.record(['TEST']);
expect(logs.length).to.equal(2);
});
it('respects disable from notify', async () => {
const { telemetry, config, logs } = setup();
await telemetry.notify(() => false);
const [key] = Array.from(config.keys());
expect(key).not.to.be.undefined;
expect(config.get(key)).to.be.false;
expect(telemetry.enabled).to.be.false;
expect(telemetry.isDisabled).to.be.true;
const [log] = logs;
expect(log).not.to.be.undefined;
expect(logs.join('')).to.match(/disabled/);
});
it('respects enable from notify', async () => {
const { telemetry, config, logs } = setup();
await telemetry.notify(() => true);
const [key] = Array.from(config.keys());
expect(key).not.to.be.undefined;
expect(config.get(key)).to.be.true;
expect(telemetry.enabled).to.be.true;
expect(telemetry.isDisabled).to.be.false;
const [log] = logs;
expect(log).not.to.be.undefined;
expect(logs.join('')).to.match(/enabled/);
});
});

View file

@ -125,7 +125,7 @@ importers:
examples/basics:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/blog:
@ -140,23 +140,23 @@ importers:
specifier: ^3.0.0-rc.1
version: link:../../packages/integrations/sitemap
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/component:
devDependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/deno:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
devDependencies:
'@astrojs/deno':
specifier: ^5.0.0-rc.1
specifier: ^5.0.0-rc.2
version: link:../../packages/integrations/deno
examples/framework-alpine:
@ -171,7 +171,7 @@ importers:
specifier: ^3.12.3
version: 3.12.3
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/framework-lit:
@ -183,7 +183,7 @@ importers:
specifier: ^0.2.1
version: 0.2.1
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
lit:
specifier: ^2.8.0
@ -207,7 +207,7 @@ importers:
specifier: ^3.0.0-rc.1
version: link:../../packages/integrations/vue
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
preact:
specifier: ^10.17.1
@ -237,7 +237,7 @@ importers:
specifier: ^1.2.1
version: 1.2.1(preact@10.17.1)
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
preact:
specifier: ^10.17.1
@ -255,7 +255,7 @@ importers:
specifier: ^18.2.7
version: 18.2.7
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
react:
specifier: ^18.2.0
@ -270,7 +270,7 @@ importers:
specifier: ^3.0.0-rc.3
version: link:../../packages/integrations/solid
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
solid-js:
specifier: ^1.7.11
@ -282,7 +282,7 @@ importers:
specifier: ^4.0.0-rc.2
version: link:../../packages/integrations/svelte
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
svelte:
specifier: ^4.2.0
@ -294,7 +294,7 @@ importers:
specifier: ^3.0.0-rc.1
version: link:../../packages/integrations/vue
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
vue:
specifier: ^3.3.4
@ -306,13 +306,13 @@ importers:
specifier: ^6.0.0-rc.1
version: link:../../packages/integrations/node
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/integration:
devDependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/middleware:
@ -321,7 +321,7 @@ importers:
specifier: ^6.0.0-rc.1
version: link:../../packages/integrations/node
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
html-minifier:
specifier: ^4.0.0
@ -330,19 +330,19 @@ importers:
examples/minimal:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/non-html-pages:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/portfolio:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/ssr:
@ -354,7 +354,7 @@ importers:
specifier: ^4.0.0-rc.2
version: link:../../packages/integrations/svelte
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
svelte:
specifier: ^4.2.0
@ -366,7 +366,7 @@ importers:
specifier: ^0.5.0-rc.1
version: link:../../packages/integrations/markdoc
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/with-markdown-plugins:
@ -375,7 +375,7 @@ importers:
specifier: ^3.0.0-rc.1
version: link:../../packages/markdown/remark
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
hast-util-select:
specifier: ^5.0.5
@ -396,7 +396,7 @@ importers:
examples/with-markdown-shiki:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
examples/with-mdx:
@ -408,7 +408,7 @@ importers:
specifier: ^3.0.0-rc.2
version: link:../../packages/integrations/preact
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
preact:
specifier: ^10.17.1
@ -423,7 +423,7 @@ importers:
specifier: ^0.5.0
version: 0.5.0(nanostores@0.9.3)(preact@10.17.1)
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
nanostores:
specifier: ^0.9.3
@ -444,7 +444,7 @@ importers:
specifier: ^1.6.0
version: 1.6.0
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
autoprefixer:
specifier: ^10.4.15
@ -462,7 +462,7 @@ importers:
examples/with-vite-plugin-pwa:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
vite-plugin-pwa:
specifier: 0.16.4
@ -474,7 +474,7 @@ importers:
examples/with-vitest:
dependencies:
astro:
specifier: ^3.0.0-rc.7
specifier: ^3.0.0-rc.8
version: link:../../packages/astro
vitest:
specifier: ^0.34.2