import { AstroIntegration } from "astro"; import { InlineConfig, ViteDevServer } from "vite"; //#region ../dev-center-schemas/src/components/base.d.ts interface BaseDevCenterComponent { compId: string; compName?: string; compType: string; compData: unknown; createdBy?: CreatedBy; createdByVersion?: string; experiments?: ComponentExperiments; } interface ComponentExperiments { enabledBy: string; } type CreatedBy = "BLOCKS" | "CLI" | "CODE_GEN" | "ONE_CLI"; //#endregion //#region ../dev-center-schemas/src/app-manifest.d.ts interface DevCenterAppManifest { appId: string; components: BaseDevCenterComponent[]; } //#endregion //#region ../astro-core/src/types.d.ts interface BaseExtension { type: string; } interface BuildMetadata { appManifestPath: string; clientDir: string; extensionsTopology: ExtensionTopology[]; generateAppDeploymentGroupId?: boolean; outDir: string; serverDir?: string; serverUrlPlaceholder: string; staticsUrlPlaceholder: string; } type CreateExtensionViteConfig = (opts: { name: string; config: ((context: ExtensionViteConfigContext) => InlineConfig) | InlineConfig; }) => InlineConfig; interface ExtensionTopology { id: string; type: string; topology: Record; } interface ExtensionViteConfigContext { extensionId: string; extensionName: string; integrationName: string; outputDir: string; } interface IntegrationHooks { /** * Called before the app manifest is created. * * Let's integrations contribute or change the app manifest. */ "wix:app-metadata:setup": (options: { model: IntegrationModel; serverUrlPlaceholder: string; staticsUrlPlaceholder: string; updateAppManifest: (newAppManifest: Partial) => void; updateAppManifestComponent: (compId: string, updater: (current: BaseDevCenterComponent) => BaseDevCenterComponent | Promise) => Promise; updateExtensionsTopology: (newExtensionsTopology: ExtensionTopology[]) => void; }) => Promise | void; /** * Called after every `wix:app-metadata:setup` hook has run, with the fully * assembled app manifest. */ "wix:app-metadata:complete": (options: { appManifest: DevCenterAppManifest; model: IntegrationModel; updateAppManifest: (newAppManifest: DevCenterAppManifest) => void; }) => Promise | void; /** * Called after the wix model has been set up initially. */ "wix:model:setup": (options: { model: IntegrationModel; }) => Promise | void; /** * Called during `astro dev`, after a change has been made to files that affect the * wix model. */ "wix:model:changed": (options: { model: IntegrationModel; }) => Promise | void; /** * Called after main astro dev server has been started. */ "wix:server:start": (options: { createExtensionViteConfig: CreateExtensionViteConfig; setupExtensionProxy: (server: ViteDevServer) => void; }) => Promise | void; /** * Wrapper around `astro:build:setup`, called during `astro build`. */ "wix:build:setup": (options: { createExtensionViteConfig: CreateExtensionViteConfig; target: "client" | "server"; updateConfig: (newConfig: InlineConfig) => void; vite: InlineConfig; }) => Promise | void; /** * Allows to enrich build metadata from within an integration/adapter. */ "wix:build:metadata": (options: { updateMetadata: (metadata: Partial) => void; }) => void; /** * Called after build is done for some cleanup on plugin level */ "wix:build:cleanup": () => Promise; } interface IntegrationModel { appId: string; env: Record; extensions: BaseExtension[]; isFallbackManifestBuild: boolean; rootDir: string; srcDir: string; } type WixIntegration = AstroIntegration & { hooks: { [K in keyof IntegrationHooks]?: IntegrationHooks[K] }; }; //#endregion //#region src/index.d.ts declare const createIntegration: () => WixIntegration; //#endregion export { createIntegration as default };