From 8d361169b8e487933d671ce347f0ce74922c80cc Mon Sep 17 00:00:00 2001 From: Rishi Raj Jain Date: Mon, 18 Sep 2023 15:05:27 +0530 Subject: [PATCH 1/5] fix: islands are not being rendered correctly (#8580) --- .changeset/eighty-trainers-accept.md | 5 +++++ packages/astro/src/runtime/server/scripts.ts | 6 +++--- 2 files changed, 8 insertions(+), 3 deletions(-) create mode 100644 .changeset/eighty-trainers-accept.md diff --git a/.changeset/eighty-trainers-accept.md b/.changeset/eighty-trainers-accept.md new file mode 100644 index 000000000000..c4bb890a10d2 --- /dev/null +++ b/.changeset/eighty-trainers-accept.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +add hide to style & script generated for island diff --git a/packages/astro/src/runtime/server/scripts.ts b/packages/astro/src/runtime/server/scripts.ts index 47cd122f1c05..791be320187e 100644 --- a/packages/astro/src/runtime/server/scripts.ts +++ b/packages/astro/src/runtime/server/scripts.ts @@ -1,7 +1,7 @@ import type { SSRResult } from '../../@types/astro.js'; import islandScript from './astro-island.prebuilt.js'; -const ISLAND_STYLES = ``; +const ISLAND_STYLES = ``; export function determineIfNeedsHydrationScript(result: SSRResult): boolean { if (result._metadata.hasHydrationScript) { @@ -36,12 +36,12 @@ export function getPrescripts(result: SSRResult, type: PrescriptType, directive: // deps to be loaded immediately. switch (type) { case 'both': - return `${ISLAND_STYLES}`; case 'directive': - return ``; + return ``; } return ''; } From 95b5f6280d124f8d6f866dc3286406c272ee91bf Mon Sep 17 00:00:00 2001 From: Erika <3019731+Princesseuh@users.noreply.github.com> Date: Mon, 18 Sep 2023 11:39:21 +0200 Subject: [PATCH 2/5] fix(assets): Fix misc types issues (#8568) * fix(assets): Fix misc types issues * fix: remove unnecessary change * chore: changeset --- .changeset/fair-teachers-protect.md | 5 +++++ packages/astro/client.d.ts | 4 +--- packages/astro/content-types.template.d.ts | 1 + packages/astro/src/@types/astro.ts | 1 + packages/astro/src/assets/internal.ts | 2 +- packages/astro/src/assets/types.ts | 5 ++++- 6 files changed, 13 insertions(+), 5 deletions(-) create mode 100644 .changeset/fair-teachers-protect.md diff --git a/.changeset/fair-teachers-protect.md b/.changeset/fair-teachers-protect.md new file mode 100644 index 000000000000..df8215b9f795 --- /dev/null +++ b/.changeset/fair-teachers-protect.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix small types issues related to `astro:assets`'s AVIF support and `getImage` diff --git a/packages/astro/client.d.ts b/packages/astro/client.d.ts index 146ab8355ecf..5f396b522f4c 100644 --- a/packages/astro/client.d.ts +++ b/packages/astro/client.d.ts @@ -48,9 +48,7 @@ declare module 'astro:assets' { * This is functionally equivalent to using the `` component, as the component calls this function internally. */ getImage: ( - options: - | import('./dist/assets/types.js').ImageTransform - | import('./dist/assets/types.js').UnresolvedImageTransform + options: import('./dist/assets/types.js').UnresolvedImageTransform ) => Promise; imageConfig: import('./dist/@types/astro.js').AstroConfig['image']; getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService; diff --git a/packages/astro/content-types.template.d.ts b/packages/astro/content-types.template.d.ts index eb560193d4a7..4d59d140fd2e 100644 --- a/packages/astro/content-types.template.d.ts +++ b/packages/astro/content-types.template.d.ts @@ -33,6 +33,7 @@ declare module 'astro:content' { import('astro/zod').ZodLiteral<'webp'>, import('astro/zod').ZodLiteral<'gif'>, import('astro/zod').ZodLiteral<'svg'>, + import('astro/zod').ZodLiteral<'avif'>, ] >; }>; diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index 10e15b6ffd74..109629428ca8 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -48,6 +48,7 @@ export type { ImageQuality, ImageQualityPreset, ImageTransform, + UnresolvedImageTransform, } from '../assets/types.js'; export type { RemotePattern } from '../assets/utils/remotePattern.js'; export type { SSRManifest } from '../core/app/types.js'; diff --git a/packages/astro/src/assets/internal.ts b/packages/astro/src/assets/internal.ts index 9d2c9eb0e1d8..f6c3b0b52cb9 100644 --- a/packages/astro/src/assets/internal.ts +++ b/packages/astro/src/assets/internal.ts @@ -67,7 +67,7 @@ export async function getConfiguredImageService(): Promise { } export async function getImage( - options: ImageTransform | UnresolvedImageTransform, + options: UnresolvedImageTransform, imageConfig: AstroConfig['image'] ): Promise { if (!options || typeof options !== 'object') { diff --git a/packages/astro/src/assets/types.ts b/packages/astro/src/assets/types.ts index 0bf740d573bc..1712cda1cb85 100644 --- a/packages/astro/src/assets/types.ts +++ b/packages/astro/src/assets/types.ts @@ -28,8 +28,11 @@ export interface ImageMetadata { orientation?: number; } +/** + * A yet to be resolved image transform. Used by `getImage` + */ export type UnresolvedImageTransform = Omit & { - src: Promise<{ default: ImageMetadata }>; + src: ImageMetadata | string | Promise<{ default: ImageMetadata }>; }; /** From c9bbd304cac3cf1e95244fdc853bbea387929181 Mon Sep 17 00:00:00 2001 From: Miguel Carneiro Date: Mon, 18 Sep 2023 10:41:38 +0100 Subject: [PATCH 3/5] Tailwind configuration file changed from `cjs` to `ts` (#8583) --- packages/integrations/tailwind/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/integrations/tailwind/README.md b/packages/integrations/tailwind/README.md index 635b2cb83e65..8634d4b16c1d 100644 --- a/packages/integrations/tailwind/README.md +++ b/packages/integrations/tailwind/README.md @@ -140,7 +140,7 @@ You can now [import your own `base.css` as a local stylesheet](https://docs.astr ## Examples - The [Astro Tailwind Starter](https://github.com/withastro/astro/tree/latest/examples/with-tailwindcss?on=github) gets you up and running with a base for your project that uses Tailwind for styling -- Astro's homepage uses Tailwind. Check out its [Tailwind configuration file](https://github.com/withastro/astro.build/blob/main/tailwind.config.cjs) or an [example component](https://github.com/withastro/astro.build/blob/main/src/components/Checkbox.astro) +- Astro's homepage uses Tailwind. Check out its [Tailwind configuration file](https://github.com/withastro/astro.build/blob/main/tailwind.config.ts) or an [example component](https://github.com/withastro/astro.build/blob/main/src/components/Checkbox.astro) - The [Astro Ink](https://github.com/one-aalam/astro-ink), [Sarissa Blog](https://github.com/iozcelik/SarissaBlogAstroStarter), and [Creek](https://github.com/robertguss/Astro-Theme-Creek) themes use Tailwind for styling - [Browse Astro Tailwind projects on GitHub](https://github.com/search?q=%22%40astrojs%2Ftailwind%22%3A+path%3A%2Fpackage.json&type=code) for more examples! From 3da5d8404e56a05da93f6b0a70841acda5ca1a8f Mon Sep 17 00:00:00 2001 From: Alexander Niebuhr Date: Mon, 18 Sep 2023 11:44:19 +0200 Subject: [PATCH 4/5] feat(@astro/cloudflare): improve DX for runtime typing (#8560) --- .changeset/thin-pigs-mate.md | 5 +++++ packages/integrations/cloudflare/README.md | 12 ++++++++++-- .../integrations/cloudflare/src/server.advanced.ts | 5 ++--- .../integrations/cloudflare/src/server.directory.ts | 4 ++-- 4 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 .changeset/thin-pigs-mate.md diff --git a/.changeset/thin-pigs-mate.md b/.changeset/thin-pigs-mate.md new file mode 100644 index 000000000000..6a764cf18b4e --- /dev/null +++ b/.changeset/thin-pigs-mate.md @@ -0,0 +1,5 @@ +--- +'@astrojs/cloudflare': patch +--- + +add the option to type environment variables using a generic diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index 8d8b3c041576..e8a1db204e39 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -115,8 +115,12 @@ If you're using the `advanced` runtime, you can type the `runtime` object as fol /// import type { AdvancedRuntime } from '@astrojs/cloudflare'; +type ENV = { + SERVER_URL: string; +} + declare namespace App { - interface Locals extends AdvancedRuntime { + interface Locals extends AdvancedRuntime { user: { name: string; surname: string; @@ -132,8 +136,12 @@ If you're using the `directory` runtime, you can type the `runtime` object as fo /// import type { DirectoryRuntime } from '@astrojs/cloudflare'; +type ENV = { + SERVER_URL: string; +} + declare namespace App { - interface Locals extends DirectoryRuntime { + interface Locals extends DirectoryRuntime { user: { name: string; surname: string; diff --git a/packages/integrations/cloudflare/src/server.advanced.ts b/packages/integrations/cloudflare/src/server.advanced.ts index 6e305b1b96cc..ac6e0fe5547c 100644 --- a/packages/integrations/cloudflare/src/server.advanced.ts +++ b/packages/integrations/cloudflare/src/server.advanced.ts @@ -9,13 +9,12 @@ if (!isNode) { type Env = { ASSETS: { fetch: (req: Request) => Promise }; - name: string; }; -export interface AdvancedRuntime { +export interface AdvancedRuntime { runtime: { waitUntil: (promise: Promise) => void; - env: Env; + env: Env & T; cf: CFRequest['cf']; caches: typeof caches; }; diff --git a/packages/integrations/cloudflare/src/server.directory.ts b/packages/integrations/cloudflare/src/server.directory.ts index 48c97392cc03..ffd4ba87a696 100644 --- a/packages/integrations/cloudflare/src/server.directory.ts +++ b/packages/integrations/cloudflare/src/server.directory.ts @@ -7,10 +7,10 @@ if (!isNode) { process.env = getProcessEnvProxy(); } -export interface DirectoryRuntime { +export interface DirectoryRuntime { runtime: { waitUntil: (promise: Promise) => void; - env: EventContext['env']; + env: EventContext['env'] & T; cf: CFRequest['cf']; caches: typeof caches; }; From 60249558820bf7540ae7cf883686ac9fdd2dabe0 Mon Sep 17 00:00:00 2001 From: ematipico Date: Mon, 18 Sep 2023 09:47:02 +0000 Subject: [PATCH 5/5] [ci] format --- packages/integrations/cloudflare/README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/integrations/cloudflare/README.md b/packages/integrations/cloudflare/README.md index e8a1db204e39..27e621853b7e 100644 --- a/packages/integrations/cloudflare/README.md +++ b/packages/integrations/cloudflare/README.md @@ -117,7 +117,7 @@ import type { AdvancedRuntime } from '@astrojs/cloudflare'; type ENV = { SERVER_URL: string; -} +}; declare namespace App { interface Locals extends AdvancedRuntime { @@ -138,7 +138,7 @@ import type { DirectoryRuntime } from '@astrojs/cloudflare'; type ENV = { SERVER_URL: string; -} +}; declare namespace App { interface Locals extends DirectoryRuntime {