From 29d630508a6e25b14f23fd8f2c6663970a7d27bf Mon Sep 17 00:00:00 2001 From: Luiz Ferraz Date: Sat, 13 Apr 2024 06:39:18 -0300 Subject: [PATCH] feat!: add support for subtyping and extra integration fields (#98) Co-authored-by: Florian Lefebvre Co-authored-by: Bryce Russell --- .changeset/nasty-waves-fetch.md | 28 ++ .../content/docs/core/define-integration.mdx | 75 ++++- docs/src/content/docs/core/define-plugin.mdx | 2 +- docs/src/content/docs/core/define-utility.mdx | 16 +- docs/src/content/docs/core/with-plugins.mdx | 34 +- docs/src/content/docs/dev/hmr-integration.mdx | 22 +- .../docs/getting-started/upgrade-guide.mdx | 31 ++ .../content/docs/getting-started/usage.mdx | 12 +- .../add-devtoolbar-framework-app.mdx | 98 +++--- docs/src/content/docs/utilities/add-dts.mdx | 72 +++-- .../docs/utilities/add-integration.mdx | 14 +- .../docs/utilities/add-virtual-imports.mdx | 50 +-- .../docs/utilities/add-vite-plugin.mdx | 12 +- .../docs/utilities/has-integration.mdx | 74 +++-- .../docs/utilities/has-vite-plugin.mdx | 12 +- .../docs/utilities/inject-dev-route.mdx | 14 +- .../docs/utilities/watch-directory.mdx | 8 +- package/src/core/define-integration.ts | 24 +- package/src/core/with-plugins.ts | 36 ++- package/src/dev/hmr-integration.ts | 6 +- package/tests/unit/define-integration.spec.ts | 31 +- pnpm-lock.yaml | 298 ++---------------- 22 files changed, 470 insertions(+), 499 deletions(-) create mode 100644 .changeset/nasty-waves-fetch.md diff --git a/.changeset/nasty-waves-fetch.md b/.changeset/nasty-waves-fetch.md new file mode 100644 index 00000000..59c4e101 --- /dev/null +++ b/.changeset/nasty-waves-fetch.md @@ -0,0 +1,28 @@ +--- +"astro-integration-kit": minor +--- + +Updates `defineIntegration` `setup` returned object shape to allow extra properties + +Previously the return of the `setup` function passed to `defineIntegration` was the Astro hooks defined by the integration, and would be set as the `hooks` property in the final integration object. + +Now, the expected return of `setup` is the properties of the integration object itself: + +```ts title="my-integration.ts" ins={7,11} +import { defineIntegration } from "astro-integration-kit"; + +export default defineIntegration({ + name: "my-integration", + setup({ name }) { + return { + hooks: { + "astro:config:setup": () => { + // ... + }, + }, + }; + }, +}); +``` + +If you are using the `withPlugins` utility, you don't need to do anything since that utility now returns the updated shape. diff --git a/docs/src/content/docs/core/define-integration.mdx b/docs/src/content/docs/core/define-integration.mdx index be39a2d2..a6d92ce2 100644 --- a/docs/src/content/docs/core/define-integration.mdx +++ b/docs/src/content/docs/core/define-integration.mdx @@ -18,11 +18,13 @@ export default defineIntegration({ }), setup({ options, name }) { return { - "astro:config:setup": (params) => { - addDts(params, { - name, - content: `declare module ${JSON.stringify(options.virtualModuleId)} {}` - }) + hooks: { + "astro:config:setup": (params) => { + addDts(params, { + name, + content: `declare module ${JSON.stringify(options.virtualModuleId)} {}` + }) + } } } } @@ -87,7 +89,7 @@ import { defineIntegration } from "astro-integration-kit"; export default defineIntegration({ // ... setup() { - return {} + return {hooks: {}} } }) ``` @@ -99,7 +101,7 @@ import { defineIntegration } from "astro-integration-kit"; export default defineIntegration({ // ... setup({ options, name }) { - return {} + return {hooks: {}} } }) ``` @@ -119,7 +121,7 @@ If you want to use those hooks on your integration or plugin, you can import tha ### Astro DB (`@astrojs/db`) -```ts title="my-integration/index.ts" ins={2,8-10} +```ts title="my-integration/index.ts" ins={2,9-11} import { defineIntegration } from "astro-integration-kit"; import "astro-integration-kit/extras/db"; @@ -127,10 +129,63 @@ export default defineIntegration({ // ... setup() { return { - "astro:db:setup": ({ extendDb }) => { - // ... + hooks: { + "astro:db:setup": ({ extendDb }) => { + // ... + }, }, }; }, }); ``` + +## Defining extra integration fields + +Any extra property present on the return of `setup` will be present on the integration object returned by initializing the integration with the options. + +You can use this to define fields you might want to access from outside your integration while having access to it's internal state. + +```ts title="my-integration.ts" ins={13-20} +import { defineIntegration } from "astro-integration-kit"; + +export default defineIntegration({ + // ... + setup() { + let counter = 0; + return { + hooks: { + "astro:config:setup": ({ logger }) => { + logger.info(`Counter: ${counter++}`); + }, + }, + api: { + get counter() { + return counter; + }, + increment() { + counter++; + }, + }, + }; + }, +}); +``` + +```ts +import { defineConfig } from "astro/config"; +import myIntegration from "./my-integration"; + +const integration = myIntegration(); + +console.log(myIntegration.api.counter); // 0 + +myIntegration.api.increment(); + +console.log(myIntegration.api.counter); // 1 + +export default defineConfig({ + // Will log "Counter: 1" during setup + integrations: [myIntegration], +}); +``` + diff --git a/docs/src/content/docs/core/define-plugin.mdx b/docs/src/content/docs/core/define-plugin.mdx index 73d1f447..49859a33 100644 --- a/docs/src/content/docs/core/define-plugin.mdx +++ b/docs/src/content/docs/core/define-plugin.mdx @@ -13,7 +13,7 @@ This utility is for advanced use-cases. It's useful for developers that want to about the internals. ::: -```ts title="package/plugins/add-vite-plugin.ts" +```ts title="package/plugins/has-vite-plugin.ts" import type { AstroConfig } from "astro"; import type { Plugin, PluginOption } from "vite"; import { definePlugin } from "astro-integration-kit"; diff --git a/docs/src/content/docs/core/define-utility.mdx b/docs/src/content/docs/core/define-utility.mdx index d622e927..ca9f18a5 100644 --- a/docs/src/content/docs/core/define-utility.mdx +++ b/docs/src/content/docs/core/define-utility.mdx @@ -73,7 +73,7 @@ Even though the syntax looks a bit scary, it's actually very simple! 5. Use the utility in your integration: - ```ts "params" {10-13} + ```ts "params" {11-14} import { defineIntegration, createResolver, injectDevRoute } from "astro-integration-kit" export const integration = defineIntegration({ @@ -82,15 +82,17 @@ Even though the syntax looks a bit scary, it's actually very simple! const { resolve } = createResolver(import.meta.url) return { - "astro:config:setup": (params) => { - injectDevRoute(params, { - pattern: "/", - entrypoint: resolve("./pages/index.astro") - }) + hooks: { + "astro:config:setup": (params) => { + injectDevRoute(params, { + pattern: "/", + entrypoint: resolve("./pages/index.astro") + }) + } } } } }) ``` - \ No newline at end of file + diff --git a/docs/src/content/docs/core/with-plugins.mdx b/docs/src/content/docs/core/with-plugins.mdx index db9b2abe..7b950502 100644 --- a/docs/src/content/docs/core/with-plugins.mdx +++ b/docs/src/content/docs/core/with-plugins.mdx @@ -16,9 +16,41 @@ export default defineIntegration({ name, plugins: [hasVitePluginPlugin], hooks: { - "astro:config:setup": ({ hasVitePluginPlugin }) => {} + "astro:config:setup": ({ hasVitePlugin }) => {} } }) } }) ``` + +## Defining extra integration fields + +Any extra property (not `name`, `plugins` or `hooks`) passed to `withPlugins` are returned unchanged. + +You can use this to define fields you might want to access from outside your integration while having access to it's internal state. + +```ts title="my-integration.ts" "withPlugins" +import { defineIntegration, withPlugins } from "astro-integration-kit"; + +export default defineIntegration({ + // ... + setup() { + let counter = 0; + return withPlugins({ + hooks: { + "astro:config:setup": ({ logger }) => { + logger.info(`Counter: ${counter++}`); + }, + }, + api: { + get counter() { + return counter; + }, + increment() { + counter++; + }, + }, + }); + }, +}); +``` diff --git a/docs/src/content/docs/dev/hmr-integration.mdx b/docs/src/content/docs/dev/hmr-integration.mdx index 60b6e71a..1e94cbd2 100644 --- a/docs/src/content/docs/dev/hmr-integration.mdx +++ b/docs/src/content/docs/dev/hmr-integration.mdx @@ -9,7 +9,7 @@ Until now, we recommended `watchIntegration` to enable HMR in development. Howev From now on, we recommend that you use dynamic imports in your local playgrounds, alongside the new `hmrIntegration` integration exported from `astro-integration-kit/dev`. -```ts title="package/src/integration.ts" del={3-4,10,13} +```ts title="package/src/integration.ts" del={3-4,10,14} import { defineIntegration, createResolver, @@ -21,8 +21,10 @@ export const integration = defineIntegration({ setup() { const { resolve } = createResolver(import.meta.url) return { - "astro:config:setup": (params) => { - watchIntegration(params, resolve()) + hooks: { + "astro:config:setup": (params) => { + watchIntegration(params, resolve()) + } } } } @@ -37,11 +39,11 @@ import { hmrIntegration } from "astro-integration-kit/dev"; const { default: packageName } = await import("package-name"); export default defineConfig({ - integrations: [ - packageName(), - hmrIntegration({ - directory: createResolver(import.meta.url).resolve("../package/dist") - }) - ], + integrations: [ + packageName(), + hmrIntegration({ + directory: createResolver(import.meta.url).resolve("../package/dist") + }) + ], }); -``` \ No newline at end of file +``` diff --git a/docs/src/content/docs/getting-started/upgrade-guide.mdx b/docs/src/content/docs/getting-started/upgrade-guide.mdx index 051ac704..30ce4a2a 100644 --- a/docs/src/content/docs/getting-started/upgrade-guide.mdx +++ b/docs/src/content/docs/getting-started/upgrade-guide.mdx @@ -7,6 +7,37 @@ import { Tabs, TabItem } from '@astrojs/starlight/components'; Features get added and removed, and breaking changes are introduced! This documents how to migrate. +## `0.11.0` + +--- + +### `defineIntegration` `setup` return type updated + +Previously the return of the `setup` function passed to `defineIntegration` was the Astro hooks defined by the integration, and would be set as the `hooks` property in the final integration object. + +Now, the expected return of `setup` is the properties of the integration object itself: + +```ts title="my-integration.ts" ins={7,11} +import { defineIntegration } from "astro-integration-kit"; + +export default defineIntegration({ + name: "my-integration", + setup({ name }) { + return { + hooks: { + "astro:config:setup": () => { + // ... + }, + }, + }; + }, +}); +``` + +:::note +If you were using the `withPlugins` utility, you don't need to do anything since that utility now returns the updated shape. +::: + ## `0.10.0` --- diff --git a/docs/src/content/docs/getting-started/usage.mdx b/docs/src/content/docs/getting-started/usage.mdx index fd15085a..369cb992 100644 --- a/docs/src/content/docs/getting-started/usage.mdx +++ b/docs/src/content/docs/getting-started/usage.mdx @@ -23,11 +23,13 @@ export default defineIntegration({ }), setup({ options, name }) { return { - "astro:config:setup": (params) => { - addDts(params, { - name, - content: `declare module ${JSON.stringify(options.virtualModuleId)} {}` - }) + hooks: { + "astro:config:setup": (params) => { + addDts(params, { + name, + content: `declare module ${JSON.stringify(options.virtualModuleId)} {}` + }) + } } } } diff --git a/docs/src/content/docs/utilities/add-devtoolbar-framework-app.mdx b/docs/src/content/docs/utilities/add-devtoolbar-framework-app.mdx index 08e4cd94..d0a32cf9 100644 --- a/docs/src/content/docs/utilities/add-devtoolbar-framework-app.mdx +++ b/docs/src/content/docs/utilities/add-devtoolbar-framework-app.mdx @@ -7,7 +7,7 @@ import { Tabs, TabItem, LinkCard, Aside } from '@astrojs/starlight/components'; `addDevToolbarFrameworkApp` allows you to register a framework component as a Dev Toolbar App! You can now use a React, Preact, Solid, Vue or Svelte component instead of manipulating the DOM imperatively! -```ts title="integration/index.ts" {5,20-31} +```ts title="integration/index.ts" {5,21-32} import { defineIntegration, createResolver, @@ -22,23 +22,25 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url); return { - "astro:config:setup": (params) => { - addIntegration(params, { - integration: Vue(), - }) - - addDevToolbarFrameworkApp(params, { - framework: "vue", - name: "Test Vue Plugin", - id: "my-vue-plugin", - icon: ``, - src: resolve("./my-plugin.vue"), - style: ` - h1 { - font-family: Inter; - } - `, - }) + hooks: { + "astro:config:setup": (params) => { + addIntegration(params, { + integration: Vue(), + }) + + addDevToolbarFrameworkApp(params, { + framework: "vue", + name: "Test Vue Plugin", + id: "my-vue-plugin", + icon: ``, + src: resolve("./my-plugin.vue"), + style: ` + h1 { + font-family: Inter; + } + `, + }) + } } } } @@ -134,7 +136,7 @@ The dependencies required your users need are: - Solid: `@astrojs/solid-js`, `solid-js` -```ts title="integration/index.ts" {4,7,16-18} +```ts title="integration/index.ts" {4,7,17-19} import { defineIntegration, createResolver, @@ -149,23 +151,25 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url); return { - "astro:config:setup": (params) => { - addIntegration(params, { - integration: Vue(), - }) - - addDevToolbarFrameworkApp(params, { - framework: "vue", - name: "Test Vue Plugin", - id: "my-vue-plugin", - icon: ``, - src: resolve("./my-plugin.vue"), - style: ` - h1 { - font-family: Inter; - } - `, - }) + hooks: { + "astro:config:setup": (params) => { + addIntegration(params, { + integration: Vue(), + }) + + addDevToolbarFrameworkApp(params, { + framework: "vue", + name: "Test Vue Plugin", + id: "my-vue-plugin", + icon: ``, + src: resolve("./my-plugin.vue"), + style: ` + h1 { + font-family: Inter; + } + `, + }) + } } } } @@ -218,7 +222,7 @@ pnpm exec tailwindcss -o ./src/styles.css Then you can read that file in your integration. -```ts title="integration/index.ts" {7,22} +```ts title="integration/index.ts" {7,23} import { defineIntegration, createResolver, @@ -233,15 +237,17 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url); return { - "astro:config:setup": (params) => { - addDevToolbarFrameworkApp(params, { - framework: "vue", - name: "Test Vue Plugin", - id: "my-vue-plugin", - icon: ``, - src: resolve("./my-plugin.vue"), - style: readFileSync(resolve('./styles.css'), 'utf-8'), - }) + hooks: { + "astro:config:setup": (params) => { + addDevToolbarFrameworkApp(params, { + framework: "vue", + name: "Test Vue Plugin", + id: "my-vue-plugin", + icon: ``, + src: resolve("./my-plugin.vue"), + style: readFileSync(resolve('./styles.css'), 'utf-8'), + }) + } } } } diff --git a/docs/src/content/docs/utilities/add-dts.mdx b/docs/src/content/docs/utilities/add-dts.mdx index 997ae2a7..f5592950 100644 --- a/docs/src/content/docs/utilities/add-dts.mdx +++ b/docs/src/content/docs/utilities/add-dts.mdx @@ -6,7 +6,7 @@ description: Allows to inject .d.ts file in users project. It will create a file `addDts` allows you to inject a `.d.ts` file into the user's project. It will create a file inside `.astro` and reference it from `src/env.d.ts`. For example: -```ts title="my-integration/index.ts" {3,11-14} +```ts title="my-integration/index.ts" {3,12-15} import { defineIntegration, addDts @@ -16,11 +16,13 @@ export default defineIntegration({ // ... setup() { return { - "astro:config:setup": (params) => { - addDts(params, { - name: "my-integration", - content: `declare module "virtual:my-integration" {}` - }) + hooks: { + "astro:config:setup": (params) => { + addDts(params, { + name: "my-integration", + content: `declare module "virtual:my-integration" {}` + }) + } } } } @@ -44,7 +46,7 @@ we recommend you use a `stub` approach: declare module "virtual:my-integration" {} ``` -```ts title="my-integration/index.ts" {2,13} +```ts title="my-integration/index.ts" {2,14} import { defineIntegration, createResolver, addDts } from "astro-integration-kit"; import { readFileSync } from "node:fs"; @@ -54,11 +56,13 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url) return { - "astro:config:setup": (params) => { - addDts(params, { - name: "my-integration", - content: readFileSync(resolve("./stubs/virtual-import.d.ts"), "utf-8") - }) + hooks: { + "astro:config:setup": (params) => { + addDts(params, { + name: "my-integration", + content: readFileSync(resolve("./stubs/virtual-import.d.ts"), "utf-8") + }) + } } } } @@ -71,7 +75,7 @@ If you want to generate type from user data/input (codegen), you can go for **in #### Interpolation -```ts title="my-integration/index.ts" {12-14} +```ts title="my-integration/index.ts" {13-15} import { defineIntegration, addDts } from "astro-integration-kit"; import { z } from "astro/zod" @@ -80,13 +84,15 @@ export default defineIntegration({ optionsSchema: z.object({ locales: z.array(z.string()) }), setup({ options }) { return { - "astro:config:setup": (params) => { - addDts(params, { - name: "my-integration", - content: `declare module "virtual:my-integration" { - export type Locale: ${options.locales.map(e => `"${e}"`).join(" | ")}; - }` - }) + hooks: { + "astro:config:setup": (params) => { + addDts(params, { + name: "my-integration", + content: `declare module "virtual:my-integration" { + export type Locale: ${options.locales.map(e => `"${e}"`).join(" | ")}; + }` + }) + } } } } @@ -95,7 +101,7 @@ export default defineIntegration({ #### Buffer -```ts title="my-integration/index.ts" {10-15,19} +```ts title="my-integration/index.ts" {11-16,20} import { defineIntegration, addDts } from "astro-integration-kit"; import { z } from "astro/zod" @@ -104,18 +110,20 @@ export default defineIntegration({ optionsSchema: z.object({ locales: z.array(z.string()) }), setup({ options }) { return { - "astro:config:setup": (params) => { - let content = `declare module "virtual:my-integration" { - export type Locale:` - for (const locale of locales) { - content += ` | ${locale}` + hooks: { + "astro:config:setup": (params) => { + let content = `declare module "virtual:my-integration" { + export type Locale:` + for (const locale of locales) { + content += ` | ${locale}` + } + content += ";\n}" + + addDts(params, { + name: "my-integration", + content + }) } - content += ";\n}" - - addDts(params, { - name: "my-integration", - content - }) } } } diff --git a/docs/src/content/docs/utilities/add-integration.mdx b/docs/src/content/docs/utilities/add-integration.mdx index a723f749..ea63a462 100644 --- a/docs/src/content/docs/utilities/add-integration.mdx +++ b/docs/src/content/docs/utilities/add-integration.mdx @@ -7,7 +7,7 @@ description: Allows you to add an integration from within an integration. It will also do a check using [hasIntegration](/utilities/has-integration) to check whether the integration you're trying to add has already been added. If it has, it won't add it again. -```ts title="my-integration/index.ts" {3,5,12-14} +```ts title="my-integration/index.ts" {3,5,13-15} import { defineIntegration, addIntegration @@ -18,10 +18,12 @@ export default defineIntegration({ // ... setup() { return { - "astro:config:setup": (params) => { - addIntegration(params, { - integration: Vue() - }) + hooks: { + "astro:config:setup": (params) => { + addIntegration(params, { + integration: Vue() + }) + } } } } @@ -40,4 +42,4 @@ addIntegration(params, { integration: Vue(), ensureUnique: false }) -``` \ No newline at end of file +``` diff --git a/docs/src/content/docs/utilities/add-virtual-imports.mdx b/docs/src/content/docs/utilities/add-virtual-imports.mdx index b9eab44e..74c6e7e7 100644 --- a/docs/src/content/docs/utilities/add-virtual-imports.mdx +++ b/docs/src/content/docs/utilities/add-virtual-imports.mdx @@ -5,7 +5,7 @@ description: Allows adding Vite virtual modules easily to access data across you `addVirtualImports` allows you to create virtual modules and share data from your integration. For example: -```ts title="my-integration/index.ts" {3,11-16,18-32} "name" +```ts title="my-integration/index.ts" {3,12-17,19-33} "name" import { defineIntegration, addVirtualImports @@ -15,29 +15,31 @@ export default defineIntegration({ // ... setup({ name }) { return { - "astro:config:setup": (params) => { - addVirtualImports(params, { - name, - imports: { - 'virtual:my-integration/config': `export default ${JSON.stringify({ foo: "bar" })}`, - } - }) - - addVirtualImports(params, { - name, - imports: [ - { - id: "virtual:my-integration/advanced", - content: "export const foo = 'server'", - context: "server" - }, - { - id: "virtual:my-integration/advanced", - content: "export const foo = 'client'", - context: "client" - }, - ] - }) + hooks: { + "astro:config:setup": (params) => { + addVirtualImports(params, { + name, + imports: { + 'virtual:my-integration/config': `export default ${JSON.stringify({ foo: "bar" })}`, + } + }) + + addVirtualImports(params, { + name, + imports: [ + { + id: "virtual:my-integration/advanced", + content: "export const foo = 'server'", + context: "server" + }, + { + id: "virtual:my-integration/advanced", + content: "export const foo = 'client'", + context: "client" + }, + ] + }) + } } } } diff --git a/docs/src/content/docs/utilities/add-vite-plugin.mdx b/docs/src/content/docs/utilities/add-vite-plugin.mdx index 646c5a96..1ba253b2 100644 --- a/docs/src/content/docs/utilities/add-vite-plugin.mdx +++ b/docs/src/content/docs/utilities/add-vite-plugin.mdx @@ -6,7 +6,7 @@ description: Allows adding Vite plugins easily. `addVitePlugin` allows you add a [vite plugin](https://vitejs.dev/guide/using-plugins) to the Astro config. For example: -```ts title="my-integration/index.ts" {3,12-14} +```ts title="my-integration/index.ts" {3,13-15} import { defineIntegration, addVitePlugin @@ -17,10 +17,12 @@ export default defineIntegration({ // ... setup() { return { - "astro:config:setup": (params) => { - addVitePlugin(params, { - plugin: VitePWA({ registerType: 'autoUpdate' }) - }) + hooks: { + "astro:config:setup": (params) => { + addVitePlugin(params, { + plugin: VitePWA({ registerType: 'autoUpdate' }) + }) + } } } } diff --git a/docs/src/content/docs/utilities/has-integration.mdx b/docs/src/content/docs/utilities/has-integration.mdx index 0c023449..6f1a3251 100644 --- a/docs/src/content/docs/utilities/has-integration.mdx +++ b/docs/src/content/docs/utilities/has-integration.mdx @@ -5,7 +5,7 @@ description: Checks whether an integration been added to the Astro config. `hasIntegration` checks whether an integration has already been added to the Astro config. For example: -```ts title="my-integration/index.ts" {3,13} +```ts title="my-integration/index.ts" {3,14} import { defineIntegration, hasIntegration @@ -15,11 +15,13 @@ export default defineIntegration({ // ... setup() { return { - "astro:config:setup": (params) => { - const { logger } = params + hooks: { + "astro:config:setup": (params) => { + const { logger } = params - if (hasIntegration(params, { name: "@astrojs/tailwind" })) { - logger.info("Tailwind is installed!"); + if (hasIntegration(params, { name: "@astrojs/tailwind" })) { + logger.info("Tailwind is installed!"); + } } } } @@ -35,7 +37,7 @@ For that use-case, this utility accepts optional `position` and `relativeTo` par Checking for the presence of an integration in relation to an uninstalled integration will result in an error. -```ts title="my-integration/index.ts" {14-16,22-24,30-32,38-40} +```ts title="my-integration/index.ts" {15-17,23-25,31-33,39-41} import { defineIntegration, hasIntegration @@ -45,39 +47,41 @@ export default defineIntegration({ // ... setup({ name }) { return { - "astro:config:setup": (params) => { - const { logger } = params + hooks: { + "astro:config:setup": (params) => { + const { logger } = params - if (hasIntegration(params, { - name: "@astrojs/tailwind", - position: "before", - relativeTo: name - })) { - logger.info("Tailwind is installed before my-integration"); - } + if (hasIntegration(params, { + name: "@astrojs/tailwind", + position: "before", + relativeTo: name + })) { + logger.info("Tailwind is installed before my-integration"); + } - if (hasIntegration(params, { - name: "astro-env", - position: "after", - relativeTo: name - })) { - logger.info("AstroEnv is installed after my-integration"); - } + if (hasIntegration(params, { + name: "astro-env", + position: "after", + relativeTo: name + })) { + logger.info("AstroEnv is installed after my-integration"); + } - if (hasIntegration(params, { - name: "astro-expressive-code", - position: "before", - relativeTo: "@astrojs/mdx" - })) { - logger.info("Expressive Code is installed before MDX"); - } + if (hasIntegration(params, { + name: "astro-expressive-code", + position: "before", + relativeTo: "@astrojs/mdx" + })) { + logger.info("Expressive Code is installed before MDX"); + } - if (hasIntegration(params, { - name: "astro-expressive-code", - position: "after", - relativeTo: "@astrojs/tailwind" - })) { - logger.info("Expressive Code is installed after Tailwind"); + if (hasIntegration(params, { + name: "astro-expressive-code", + position: "after", + relativeTo: "@astrojs/tailwind" + })) { + logger.info("Expressive Code is installed after Tailwind"); + } } } } diff --git a/docs/src/content/docs/utilities/has-vite-plugin.mdx b/docs/src/content/docs/utilities/has-vite-plugin.mdx index 9d5d2239..eb506dfc 100644 --- a/docs/src/content/docs/utilities/has-vite-plugin.mdx +++ b/docs/src/content/docs/utilities/has-vite-plugin.mdx @@ -27,11 +27,13 @@ For example: // ... setup() { return { - "astro:config:setup": (params) => { - const { logger } = params + hooks: { + "astro:config:setup": (params) => { + const { logger } = params - if (hasVitePlugin(params, { plugin: "vite-plugin-my-integration" })) { - logger.warn("Vite plugin already exists!"); + if (hasVitePlugin(params, { plugin: "vite-plugin-my-integration" })) { + logger.warn("Vite plugin already exists!"); + } } } } @@ -68,4 +70,4 @@ For example: :::caution[Limitations] `hasVitePlugin` cannot check for asynchronous Vite plugins -::: \ No newline at end of file +::: diff --git a/docs/src/content/docs/utilities/inject-dev-route.mdx b/docs/src/content/docs/utilities/inject-dev-route.mdx index 3daf4369..a65b9586 100644 --- a/docs/src/content/docs/utilities/inject-dev-route.mdx +++ b/docs/src/content/docs/utilities/inject-dev-route.mdx @@ -5,7 +5,7 @@ description: Allows to inject a route in development only. `injectDevRoute` allows you to inject a route in development only. For example: -```ts title="my-integration/index.ts" {4,14-17} +```ts title="my-integration/index.ts" {4,15-18} import { defineIntegration, createResolver, @@ -18,11 +18,13 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url); return { - "astro:config:setup": (params) => { - injectDevRoute(params, { - pattern: "/foo", - entrypoint: resolve("./pages/foo.astro") - }) + hooks: { + "astro:config:setup": (params) => { + injectDevRoute(params, { + pattern: "/foo", + entrypoint: resolve("./pages/foo.astro") + }) + } } } } diff --git a/docs/src/content/docs/utilities/watch-directory.mdx b/docs/src/content/docs/utilities/watch-directory.mdx index fca416bd..16d07f7a 100644 --- a/docs/src/content/docs/utilities/watch-directory.mdx +++ b/docs/src/content/docs/utilities/watch-directory.mdx @@ -6,7 +6,7 @@ description: In development, `watchDirectory` will reload the Astro dev server i In development, `watchDirectory` will reload the Astro dev server if any files within the directory change. For example: -```ts title="my-integration/index.ts" {4,14} +```ts title="my-integration/index.ts" {4,15} import { defineIntegration, createResolver, @@ -19,8 +19,10 @@ export default defineIntegration({ const { resolve } = createResolver(import.meta.url) return { - "astro:config:setup": (params) => { - watchDirectory(params, resolve()) + hooks: { + "astro:config:setup": (params) => { + watchDirectory(params, resolve()) + } } } } diff --git a/package/src/core/define-integration.ts b/package/src/core/define-integration.ts index 3977b126..4fe37a7b 100644 --- a/package/src/core/define-integration.ts +++ b/package/src/core/define-integration.ts @@ -3,6 +3,11 @@ import { AstroError } from "astro/errors"; import { z } from "astro/zod"; import { errorMap } from "../internal/error-map.js"; +type AstroIntegrationSetupFn = (params: { + name: string; + options: z.output; +}) => Omit; + /** * A powerful wrapper around the standard Astro Integrations API. It allows integration authors to handle user options and global logic easily. * @@ -25,6 +30,8 @@ import { errorMap } from "../internal/error-map.js"; */ export const defineIntegration = < TOptionsSchema extends z.ZodTypeAny = z.ZodNever, + TSetup extends + AstroIntegrationSetupFn = AstroIntegrationSetupFn, >({ name, optionsSchema, @@ -32,18 +39,15 @@ export const defineIntegration = < }: { name: string; optionsSchema?: TOptionsSchema; - setup: (params: { - name: string; - options: z.output; - }) => AstroIntegration["hooks"]; + setup: TSetup; }): (( ...args: [z.input] extends [never] ? [] : undefined extends z.input - ? [options?: z.input] - : [options: z.input] -) => AstroIntegration) => { - return (...args) => { + ? [options?: z.input] + : [options: z.input] +) => AstroIntegration & ReturnType) => { + return (...args): AstroIntegration & ReturnType => { const parsedOptions = (optionsSchema ?? z.never().optional()).safeParse( args[0], { @@ -60,11 +64,11 @@ export const defineIntegration = < const options = parsedOptions.data as z.output; - const hooks = setup({ name, options }); + const integration = setup({ name, options }) as ReturnType; return { name, - hooks, + ...integration, }; }; }; diff --git a/package/src/core/with-plugins.ts b/package/src/core/with-plugins.ts index 4895b1bc..db256234 100644 --- a/package/src/core/with-plugins.ts +++ b/package/src/core/with-plugins.ts @@ -8,6 +8,19 @@ import type { Hooks, } from "./types.js"; +type WithPluginsParams> = { + name: string; + plugins: TPlugins; + hooks: ExtendedHooks; +}; + +type WithPluginsReturn = Omit< + Extensions, + "name" | "plugins" | "hooks" +> & { + hooks: AstroIntegration["hooks"]; +}; + /** * Allows to extend hooks with custom parameters. Only used for advanced use-cases. * @@ -16,11 +29,19 @@ import type { * @param {Array} params.plugins * @param {import("astro".AstroIntegration["hooks"])} params.hooks */ -export const withPlugins = >({ - name, - plugins, - hooks: providedHooks, -}: { name: string; plugins: TPlugins; hooks: ExtendedHooks }) => { +export const withPlugins = < + TPlugins extends NonEmptyArray, + Extensions extends Record, +>( + options: WithPluginsParams & Extensions, +): WithPluginsReturn => { + const { + name, + plugins, + hooks: providedHooks, + ...remainingIntegrationObject + } = options; + // Overrides plugins with same name // Overrides plugins with same name, keeping only the last occurrence const resolvedPlugins = plugins @@ -64,5 +85,8 @@ export const withPlugins = >({ ]), ); - return hooks; + return { + hooks, + ...remainingIntegrationObject, + }; }; diff --git a/package/src/dev/hmr-integration.ts b/package/src/dev/hmr-integration.ts index 29bca80a..f6cf8d47 100644 --- a/package/src/dev/hmr-integration.ts +++ b/package/src/dev/hmr-integration.ts @@ -9,8 +9,10 @@ export const hmrIntegration = defineIntegration({ }), setup({ options }) { return { - "astro:config:setup": (params) => { - watchDirectory(params, options.directory); + hooks: { + "astro:config:setup": (params) => { + watchDirectory(params, options.directory); + }, }, }; }, diff --git a/package/tests/unit/define-integration.spec.ts b/package/tests/unit/define-integration.spec.ts index 3c80e8b2..f7116f2e 100644 --- a/package/tests/unit/define-integration.spec.ts +++ b/package/tests/unit/define-integration.spec.ts @@ -8,7 +8,7 @@ describe("defineIntegration", () => { test("Should run", () => { const name = "my-integration"; - const setup = () => ({}); + const setup = () => ({ hooks: {} }); expect(() => defineIntegration({ @@ -21,7 +21,7 @@ describe("defineIntegration", () => { test("Setup should get called", () => { const name = "my-integration"; const setup = vi.fn(() => { - return {}; + return { hooks: {} }; }); defineIntegration({ @@ -35,7 +35,7 @@ describe("defineIntegration", () => { test("Setup should get called with correct name", () => { const name = "my-integration"; const setup = vi.fn(() => { - return {}; + return { hooks: {} }; }); defineIntegration({ @@ -51,7 +51,7 @@ describe("defineIntegration", () => { test.skip("Setup should get called with default args", () => { const name = "my-integration"; const setup = vi.fn(() => { - return {}; + return { hooks: {} }; }); defineIntegration({ @@ -67,7 +67,7 @@ describe("defineIntegration", () => { test.skip("Setup should get called with overwritten args", () => { const name = "my-integration"; const setup = vi.fn(() => { - return {}; + return { hooks: {} }; }); const expectedOptions = { @@ -88,7 +88,7 @@ describe("defineIntegration", () => { test("Integration should have correct name", () => { const name = "my-integration"; const setup = vi.fn(() => { - return {}; + return { hooks: {} }; }); const integration = defineIntegration({ @@ -98,4 +98,23 @@ describe("defineIntegration", () => { expect(integration.name).toBe(name); }); + + test("Integration should have all extra fields from setup", () => { + const name = "my-integration"; + const setup = vi.fn(() => { + return { + hooks: {}, + config: { + foo: "bar", + }, + }; + }); + + const integration = defineIntegration({ + name, + setup, + })(); + + expect(integration.config).toStrictEqual({ foo: "bar" }); + }); }); diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index cae0bf2d..48c9b60a 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -25,7 +25,7 @@ importers: version: 0.33.5 astro: specifier: ^4.5.9 - version: 4.5.9(typescript@5.4.3) + version: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) sharp: specifier: ^0.33.3 version: 0.33.3 @@ -47,7 +47,7 @@ importers: version: 4.2.1(vite@5.2.2) astro: specifier: ^4.4.1 - version: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + version: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) pathe: specifier: ^1.1.2 version: 1.1.2 @@ -102,13 +102,13 @@ importers: version: 4.0.1(solid-js@1.8.16)(vite@5.2.2) '@astrojs/svelte': specifier: ^5.0.3 - version: 5.2.0(astro@4.5.8)(svelte@4.2.12)(typescript@5.4.3)(vite@5.2.2) + version: 5.2.0(astro@4.5.9)(svelte@4.2.12)(typescript@5.4.3)(vite@5.2.2) '@astrojs/tailwind': specifier: ^5.1.0 - version: 5.1.0(astro@4.5.8)(tailwindcss@3.4.1) + version: 5.1.0(astro@4.5.9)(tailwindcss@3.4.1) '@astrojs/vue': specifier: ^4.0.8 - version: 4.0.9(@babel/core@7.24.3)(astro@4.5.8)(vite@5.2.2)(vue@3.4.21) + version: 4.0.9(@babel/core@7.24.3)(astro@4.5.9)(vite@5.2.2)(vue@3.4.21) '@types/react': specifier: ^18.2.55 version: 18.2.67 @@ -123,7 +123,7 @@ importers: version: 5.0.4(vite@5.2.2)(vue@3.4.21) astro: specifier: ^4.1.2 - version: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + version: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) astro-integration-kit: specifier: workspace:* version: link:../package @@ -169,10 +169,10 @@ importers: dependencies: '@astrojs/vue': specifier: ^4.0.8 - version: 4.0.9(@babel/core@7.24.3)(astro@4.5.8)(vite@5.2.2)(vue@3.4.21) + version: 4.0.9(@babel/core@7.24.3)(astro@4.5.9)(vite@5.2.2)(vue@3.4.21) astro: specifier: ^4.4.5 - version: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + version: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) astro-integration-kit: specifier: workspace:* version: link:../../package @@ -212,7 +212,7 @@ packages: peerDependencies: typescript: ^5.0.0 dependencies: - '@astrojs/language-server': 2.8.3(typescript@5.4.3) + '@astrojs/language-server': 2.8.4(typescript@5.4.3) chokidar: 3.6.0 fast-glob: 3.3.2 kleur: 4.1.5 @@ -292,38 +292,6 @@ packages: resolution: {integrity: sha512-tGmHvrhpzuz0JBHaJX8GywN9g4rldVNHtkoVDC3m/DdzBO70jGoVuc0uuNVglRYnsdwkbG0K02Iw3nOOR3/Y4g==} dev: false - /@astrojs/language-server@2.8.3(typescript@5.4.3): - resolution: {integrity: sha512-tO47Lcue7OPXfIDbKVDcshwpC13yaWaTVLyiSOnQ2Yng2Z2SgcJf06Cj4xMpJqGp6s7/o/gcQWYUTl2bpkWKig==} - hasBin: true - peerDependencies: - prettier: ^3.0.0 - prettier-plugin-astro: '>=0.11.0' - peerDependenciesMeta: - prettier: - optional: true - prettier-plugin-astro: - optional: true - dependencies: - '@astrojs/compiler': 2.7.0 - '@jridgewell/sourcemap-codec': 1.4.15 - '@volar/kit': 2.1.3(typescript@5.4.3) - '@volar/language-core': 2.1.3 - '@volar/language-server': 2.1.3 - '@volar/language-service': 2.1.3 - '@volar/typescript': 2.1.3 - fast-glob: 3.3.2 - volar-service-css: 0.0.34(@volar/language-service@2.1.3) - volar-service-emmet: 0.0.34(@volar/language-service@2.1.3) - volar-service-html: 0.0.34(@volar/language-service@2.1.3) - volar-service-prettier: 0.0.34(@volar/language-service@2.1.3) - volar-service-typescript: 0.0.34(@volar/language-service@2.1.3) - volar-service-typescript-twoslash-queries: 0.0.34(@volar/language-service@2.1.3) - vscode-html-languageservice: 5.1.2 - vscode-uri: 3.0.8 - transitivePeerDependencies: - - typescript - dev: true - /@astrojs/language-server@2.8.4(typescript@5.4.3): resolution: {integrity: sha512-sJH5vGTBkhgA8+hdhzX78UUp4cFz4Mt7xkEkevD188OS5bDMkaue6hK+dtXWM47mnrXFveXA2u38K7S+5+IRjA==} hasBin: true @@ -390,7 +358,7 @@ packages: '@astrojs/markdown-remark': 4.3.1 '@mdx-js/mdx': 3.0.1 acorn: 8.11.3 - astro: 4.5.9(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) es-module-lexer: 1.4.2 estree-util-visit: 2.0.0 github-slugger: 2.0.0 @@ -485,7 +453,7 @@ packages: '@pagefind/default-ui': 1.0.4 '@types/hast': 3.0.4 '@types/mdast': 4.0.3 - astro: 4.5.9(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) astro-expressive-code: 0.33.5(astro@4.5.9) bcp-47: 2.1.0 hast-util-from-html: 2.0.1 @@ -505,7 +473,7 @@ packages: - supports-color dev: false - /@astrojs/svelte@5.2.0(astro@4.5.8)(svelte@4.2.12)(typescript@5.4.3)(vite@5.2.2): + /@astrojs/svelte@5.2.0(astro@4.5.9)(svelte@4.2.12)(typescript@5.4.3)(vite@5.2.2): resolution: {integrity: sha512-GmwbXks2WMkmAfl0rlPM/2gA1RtmZzjGV2mOceV3g7QNyjIsSYBPKrlEnSFnuR+YMvlAtWdbMFBsb3gtGxnTTg==} engines: {node: '>=18.14.1'} peerDependencies: @@ -514,7 +482,7 @@ packages: typescript: ^5.3.3 dependencies: '@sveltejs/vite-plugin-svelte': 3.0.2(svelte@4.2.12)(vite@5.2.2) - astro: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) svelte: 4.2.12 svelte2tsx: 0.6.27(svelte@4.2.12)(typescript@5.4.3) typescript: 5.4.3 @@ -523,13 +491,13 @@ packages: - vite dev: false - /@astrojs/tailwind@5.1.0(astro@4.5.8)(tailwindcss@3.4.1): + /@astrojs/tailwind@5.1.0(astro@4.5.9)(tailwindcss@3.4.1): resolution: {integrity: sha512-BJoCDKuWhU9FT2qYg+fr6Nfb3qP4ShtyjXGHKA/4mHN94z7BGcmauQK23iy+YH5qWvTnhqkd6mQPQ1yTZTe9Ig==} peerDependencies: astro: ^3.0.0 || ^4.0.0 tailwindcss: ^3.0.24 dependencies: - astro: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) autoprefixer: 10.4.19(postcss@8.4.38) postcss: 8.4.38 postcss-load-config: 4.0.2(postcss@8.4.38) @@ -553,7 +521,7 @@ packages: - supports-color dev: false - /@astrojs/vue@4.0.9(@babel/core@7.24.3)(astro@4.5.8)(vite@5.2.2)(vue@3.4.21): + /@astrojs/vue@4.0.9(@babel/core@7.24.3)(astro@4.5.9)(vite@5.2.2)(vue@3.4.21): resolution: {integrity: sha512-go+dRsDQpZYbwvMTJygw9i9W7apsI36STm/Ic4NTcTnlMGjQZlFi3GyQiPB8rstX+FpuTaCDxFSzDhqfD89tig==} engines: {node: '>=18.14.1'} peerDependencies: @@ -564,7 +532,7 @@ packages: '@vitejs/plugin-vue-jsx': 3.1.0(vite@5.2.2)(vue@3.4.21) '@vue/babel-plugin-jsx': 1.2.2(@babel/core@7.24.3) '@vue/compiler-sfc': 3.4.21 - astro: 4.5.8(@types/node@20.11.30)(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) vue: 3.4.21(typescript@5.4.3) transitivePeerDependencies: - '@babel/core' @@ -3511,19 +3479,6 @@ packages: pretty-format: 29.7.0 dev: true - /@volar/kit@2.1.3(typescript@5.4.3): - resolution: {integrity: sha512-E4gsBkYZnoQ/T1GorDCs2ndYV+3rv/SPxPbG0um1RU47sH6qX1I7Kk+1wjwTVD78TLCA8NSTq+dMapAL5mGw3Q==} - peerDependencies: - typescript: '*' - dependencies: - '@volar/language-service': 2.1.3 - '@volar/typescript': 2.1.3 - typesafe-path: 0.2.2 - typescript: 5.4.3 - vscode-languageserver-textdocument: 1.0.11 - vscode-uri: 3.0.8 - dev: true - /@volar/kit@2.1.5(typescript@5.4.3): resolution: {integrity: sha512-L4bHJ1TsKNjsmxSGBuzkUvii4EQoQAT9JoHy8aL4Y17qU/z0JWI1BzUDGpMl4oDlsc+WpWIVGo6KZAnclrUx/w==} peerDependencies: @@ -3537,34 +3492,12 @@ packages: vscode-uri: 3.0.8 dev: true - /@volar/language-core@2.1.3: - resolution: {integrity: sha512-F93KYZYqcYltG7NihfnLt/omMZOtrQtsh2+wj+cgx3xolopU+TZvmwlZWOjw3ObZGFj3SKBb4jJn6VSfSch6RA==} - dependencies: - '@volar/source-map': 2.1.3 - dev: true - /@volar/language-core@2.1.5: resolution: {integrity: sha512-u1OHmVkCFsJqNdaM2GKuMhE67TxcEnOqJNF+VtYv2Ji8DnrUaF4FAFSNxY+MRGICl+873CsSJVKas9TQtW14LA==} dependencies: '@volar/source-map': 2.1.5 dev: true - /@volar/language-server@2.1.3: - resolution: {integrity: sha512-dUet7VeDWhsHWSd8wRcE19kkIDT3rq/FC6CzTDH+y0sjnGrKwRH9ANX6KbR1HzEh71ajRL1XemK2X6N7x5VEWQ==} - dependencies: - '@volar/language-core': 2.1.3 - '@volar/language-service': 2.1.3 - '@volar/snapshot-document': 2.1.3 - '@volar/typescript': 2.1.3 - '@vscode/l10n': 0.0.16 - path-browserify: 1.0.1 - request-light: 0.7.0 - vscode-languageserver: 9.0.1 - vscode-languageserver-protocol: 3.17.5 - vscode-languageserver-textdocument: 1.0.11 - vscode-uri: 3.0.8 - dev: true - /@volar/language-server@2.1.5: resolution: {integrity: sha512-uHNVf9J4IX4g10gAMJmPoIV9RteYlM+d9yOXcPfRn5JEM+RyNue3GJT1JkoK9JPU5yAdYBEAhDjA54Sl5tC3fA==} dependencies: @@ -3581,15 +3514,6 @@ packages: vscode-uri: 3.0.8 dev: true - /@volar/language-service@2.1.3: - resolution: {integrity: sha512-0wsPSvfIP1IAP0Bskp5aCjYvLge9PTzIAiHDFK9PYmMOJqO+vgPih9IIBSded1SCxaRauSvqwGoXKdeFieoYbg==} - dependencies: - '@volar/language-core': 2.1.3 - vscode-languageserver-protocol: 3.17.5 - vscode-languageserver-textdocument: 1.0.11 - vscode-uri: 3.0.8 - dev: true - /@volar/language-service@2.1.5: resolution: {integrity: sha512-WuvEv6x/fBe3e4akhblK1E2GgpnAZNnm7sKsRPrQPTE3ED5PIfiMrWgzKB5gNZToD+d6LPxfKAaGWQCpxmSJiw==} dependencies: @@ -3599,13 +3523,6 @@ packages: vscode-uri: 3.0.8 dev: true - /@volar/snapshot-document@2.1.3: - resolution: {integrity: sha512-sXcat0I1YmmohMuq1q/tcbcYIeI9vkZwx14LEpsX/wk9DcxrEILx+d1gjRxg9EgRjQRacDZIVevnKZf6p3Fi8A==} - dependencies: - vscode-languageserver-protocol: 3.17.5 - vscode-languageserver-textdocument: 1.0.11 - dev: true - /@volar/snapshot-document@2.1.5: resolution: {integrity: sha512-UbHM95HxlLNAQ4hTSzIiMj2m19zmwrympviItbx6iPRhbd0FSPGsHdrfL8nsBa9q2cIvwSEtrmA5Sg3tHy4mrg==} dependencies: @@ -3613,25 +3530,12 @@ packages: vscode-languageserver-textdocument: 1.0.11 dev: true - /@volar/source-map@2.1.3: - resolution: {integrity: sha512-j+R+NG/OlDgdNMttADxNuSM9Z26StT/Bjw0NgSydI05Vihngn9zvaP/xXwfWs5qQrRzbKVFxJebS2ks5m/URuA==} - dependencies: - muggle-string: 0.4.1 - dev: true - /@volar/source-map@2.1.5: resolution: {integrity: sha512-GIkAM6fHgDcTXcdH4i10fAiAZzO0HLIer8/pt3oZ9A0n7n4R5d1b2F8Xxzh/pgmgNoL+SrHX3MFxs35CKgfmtA==} dependencies: muggle-string: 0.4.1 dev: true - /@volar/typescript@2.1.3: - resolution: {integrity: sha512-ZZqLMih4mvu2eJAW3UCFm84OM/ojYMoA/BU/W1TctT5F2nVzNJmW4jxMWmP3wQzxCbATfTa5gLb1+BSI9NBMBg==} - dependencies: - '@volar/language-core': 2.1.3 - path-browserify: 1.0.1 - dev: true - /@volar/typescript@2.1.5: resolution: {integrity: sha512-zo9a3NrNMSkufIvHuExDGTfYv+zO7C5p2wg8fyP7vcqF/Qo0ztjb0ZfOgq/A85EO/MBc1Kj2Iu7PaOBtP++NMw==} dependencies: @@ -3934,93 +3838,12 @@ packages: peerDependencies: astro: ^4.0.0-beta || ^3.3.0 dependencies: - astro: 4.5.9(typescript@5.4.3) + astro: 4.5.9(@types/node@20.11.30)(typescript@5.4.3) hast-util-to-html: 8.0.4 remark-expressive-code: 0.33.5 dev: false - /astro@4.5.8(@types/node@20.11.30)(typescript@5.4.3): - resolution: {integrity: sha512-bhKsoZQWT6LW8aYMvTGglZTPa3rYRbcdc2buiJyFPCvSWOOyZmxqpp6vtQ+x6fXxD8P1NecM/c4g5GaPi+MokQ==} - engines: {node: '>=18.14.1', npm: '>=6.14.0'} - hasBin: true - dependencies: - '@astrojs/compiler': 2.7.0 - '@astrojs/internal-helpers': 0.3.0 - '@astrojs/markdown-remark': 4.3.1 - '@astrojs/telemetry': 3.0.4 - '@babel/core': 7.24.3 - '@babel/generator': 7.24.1 - '@babel/parser': 7.24.1 - '@babel/plugin-transform-react-jsx': 7.23.4(@babel/core@7.24.3) - '@babel/traverse': 7.24.1 - '@babel/types': 7.24.0 - '@types/babel__core': 7.20.5 - acorn: 8.11.3 - aria-query: 5.3.0 - axobject-query: 4.0.0 - boxen: 7.1.1 - chokidar: 3.6.0 - ci-info: 4.0.0 - clsx: 2.1.0 - common-ancestor-path: 1.0.1 - cookie: 0.6.0 - cssesc: 3.0.0 - debug: 4.3.4 - deterministic-object-hash: 2.0.2 - devalue: 4.3.2 - diff: 5.2.0 - dlv: 1.1.3 - dset: 3.1.3 - es-module-lexer: 1.4.2 - esbuild: 0.19.12 - estree-walker: 3.0.3 - execa: 8.0.1 - fast-glob: 3.3.2 - flattie: 1.1.1 - github-slugger: 2.0.0 - gray-matter: 4.0.3 - html-escaper: 3.0.3 - http-cache-semantics: 4.1.1 - js-yaml: 4.1.0 - kleur: 4.1.5 - magic-string: 0.30.8 - mime: 3.0.0 - ora: 7.0.1 - p-limit: 5.0.0 - p-queue: 8.0.1 - path-to-regexp: 6.2.1 - preferred-pm: 3.1.3 - prompts: 2.4.2 - rehype: 13.0.1 - resolve: 1.22.8 - semver: 7.6.0 - shiki: 1.2.0 - string-width: 7.1.0 - strip-ansi: 7.1.0 - tsconfck: 3.0.3(typescript@5.4.3) - unist-util-visit: 5.0.0 - vfile: 6.0.1 - vite: 5.2.2(@types/node@20.11.30) - vitefu: 0.2.5(vite@5.2.2) - which-pm: 2.1.1 - yargs-parser: 21.1.1 - zod: 3.22.4 - zod-to-json-schema: 3.22.4(zod@3.22.4) - optionalDependencies: - sharp: 0.32.6 - transitivePeerDependencies: - - '@types/node' - - less - - lightningcss - - sass - - stylus - - sugarss - - supports-color - - terser - - typescript - dev: false - - /astro@4.5.9(typescript@5.4.3): + /astro@4.5.9(@types/node@20.11.30)(typescript@5.4.3): resolution: {integrity: sha512-GheU72Goz7dYQNKaqTxB2H49cNvHfahGSbNkTvMXk+gyHf/g633qadqlO2ZQbTUacoUWmDzvS5fhMZt2/w4naQ==} engines: {node: '>=18.14.1', npm: '>=6.14.0'} hasBin: true @@ -9888,20 +9711,6 @@ packages: - terser dev: true - /volar-service-css@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-C7ua0j80ZD7bsgALAz/cA1bykPehoIa5n+3+Ccr+YLpj0fypqw9iLUmGLX11CqzqNCO2XFGe/1eXB/c+SWrF/g==} - peerDependencies: - '@volar/language-service': ~2.1.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - dependencies: - '@volar/language-service': 2.1.3 - vscode-css-languageservice: 6.2.12 - vscode-languageserver-textdocument: 1.0.11 - vscode-uri: 3.0.8 - dev: true - /volar-service-css@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-C7ua0j80ZD7bsgALAz/cA1bykPehoIa5n+3+Ccr+YLpj0fypqw9iLUmGLX11CqzqNCO2XFGe/1eXB/c+SWrF/g==} peerDependencies: @@ -9916,19 +9725,6 @@ packages: vscode-uri: 3.0.8 dev: true - /volar-service-emmet@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-ubQvMCmHPp8Ic82LMPkgrp9ot+u2p/RDd0RyT0EykRkZpWsagHUF5HWkVheLfiMyx2rFuWx/+7qZPOgypx6h6g==} - peerDependencies: - '@volar/language-service': ~2.1.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - dependencies: - '@volar/language-service': 2.1.3 - '@vscode/emmet-helper': 2.9.2 - vscode-html-languageservice: 5.1.2 - dev: true - /volar-service-emmet@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-ubQvMCmHPp8Ic82LMPkgrp9ot+u2p/RDd0RyT0EykRkZpWsagHUF5HWkVheLfiMyx2rFuWx/+7qZPOgypx6h6g==} peerDependencies: @@ -9942,20 +9738,6 @@ packages: vscode-html-languageservice: 5.1.2 dev: true - /volar-service-html@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-kMEneea1tQbiRcyKavqdrSVt8zV06t+0/3pGkjO3gV6sikXTNShIDkdtB4Tq9vE2cQdM50TuS7utVV7iysUxHw==} - peerDependencies: - '@volar/language-service': ~2.1.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - dependencies: - '@volar/language-service': 2.1.3 - vscode-html-languageservice: 5.1.2 - vscode-languageserver-textdocument: 1.0.11 - vscode-uri: 3.0.8 - dev: true - /volar-service-html@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-kMEneea1tQbiRcyKavqdrSVt8zV06t+0/3pGkjO3gV6sikXTNShIDkdtB4Tq9vE2cQdM50TuS7utVV7iysUxHw==} peerDependencies: @@ -9970,21 +9752,6 @@ packages: vscode-uri: 3.0.8 dev: true - /volar-service-prettier@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-BNfJ8FwfPi1Wm/JkuzNjraOLdtKieGksNT/bDyquygVawv1QUzO2HB1hiMKfZGdcSFG5ZL9R0j7bBfRTfXA2gg==} - peerDependencies: - '@volar/language-service': ~2.1.0 - prettier: ^2.2 || ^3.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - prettier: - optional: true - dependencies: - '@volar/language-service': 2.1.3 - vscode-uri: 3.0.8 - dev: true - /volar-service-prettier@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-BNfJ8FwfPi1Wm/JkuzNjraOLdtKieGksNT/bDyquygVawv1QUzO2HB1hiMKfZGdcSFG5ZL9R0j7bBfRTfXA2gg==} peerDependencies: @@ -10000,17 +9767,6 @@ packages: vscode-uri: 3.0.8 dev: true - /volar-service-typescript-twoslash-queries@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-XAY2YtWKUp6ht89gxt3L5Dr46LU45d/VlBkj1KXUwNlinpoWiGN4Nm3B6DRF3VoBThAnQgm4c7WD0S+5yTzh+w==} - peerDependencies: - '@volar/language-service': ~2.1.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - dependencies: - '@volar/language-service': 2.1.3 - dev: true - /volar-service-typescript-twoslash-queries@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-XAY2YtWKUp6ht89gxt3L5Dr46LU45d/VlBkj1KXUwNlinpoWiGN4Nm3B6DRF3VoBThAnQgm4c7WD0S+5yTzh+w==} peerDependencies: @@ -10022,22 +9778,6 @@ packages: '@volar/language-service': 2.1.5 dev: true - /volar-service-typescript@0.0.34(@volar/language-service@2.1.3): - resolution: {integrity: sha512-NbAry0w8ZXFgGsflvMwmPDCzgJGx3C+eYxFEbldaumkpTAJiywECWiUbPIOfmEHgpOllUKSnhwtLlWFK4YnfQg==} - peerDependencies: - '@volar/language-service': ~2.1.0 - peerDependenciesMeta: - '@volar/language-service': - optional: true - dependencies: - '@volar/language-service': 2.1.3 - path-browserify: 1.0.1 - semver: 7.6.0 - typescript-auto-import-cache: 0.3.2 - vscode-languageserver-textdocument: 1.0.11 - vscode-nls: 5.2.0 - dev: true - /volar-service-typescript@0.0.34(@volar/language-service@2.1.5): resolution: {integrity: sha512-NbAry0w8ZXFgGsflvMwmPDCzgJGx3C+eYxFEbldaumkpTAJiywECWiUbPIOfmEHgpOllUKSnhwtLlWFK4YnfQg==} peerDependencies: