0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Refactor/types (#11715)

* refactor: types

* feat: refactor types

* chore: organize imports

* fix: remaining references

* docs: types

* refactor: small changes

* chore: changeset
This commit is contained in:
Erika 2024-08-16 14:07:10 +02:00 committed by GitHub
parent 40b95a164d
commit d74617cbd3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
216 changed files with 2074 additions and 2097 deletions

View file

@ -0,0 +1,7 @@
---
'astro': major
---
Refactor the exported types from the `astro` module. There should normally be no breaking changes, but if you relied on some previously deprecated types, these might now have been fully removed.
In most cases, updating your code to move away from previously deprecated APIs in previous versions of Astro should be enough to fix any issues.

2
.github/labeler.yml vendored
View file

@ -40,5 +40,5 @@
- packages/integrations/vue/**
'docs pr':
- packages/astro/src/@types/astro.ts
- packages/astro/src/types/public/**
- packages/astro/src/core/errors/errors-data.ts

View file

@ -11,7 +11,7 @@ on:
- "examples/**"
- ".github/workflows/check.yml"
- "scripts/smoke/check.js"
- "packages/astro/src/@types/astro.ts"
- "packages/astro/src/types/public/**"
- "pnpm-lock.yaml"
- "packages/astro/types.d.ts"

View file

@ -229,7 +229,7 @@ jobs:
filters: |
docs:
- 'packages/integrations/*/README.md'
- 'packages/astro/src/@types/astro.ts'
- "packages/astro/src/types/public/**"
- 'packages/astro/src/core/errors/errors-data.ts'
- name: Build autogenerated docs pages from current astro branch

View file

@ -289,7 +289,7 @@ Server-side rendering (SSR) can be complicated. The Astro package (`packages/ast
- `components/`: Built-in components to use in your project (e.g. `import Code from 'astro/components/Code.astro'`)
- `src/`: Astro source
- `@types/`: TypeScript types. These are centralized to cut down on circular dependencies
- `types/`: TypeScript types. These are centralized to cut down on circular dependencies
- `cli/`: Code that powers the `astro` CLI command
- `core/`: Code that executes **in the top-level scope** (in Node). Within, youll find code that powers the `astro build` and `astro dev` commands, as well as top-level SSR code.
- `runtime/`: Code that executes **in different scopes** (i.e. not in a pure Node context). Youll have to think about code differently here.

View file

@ -17,23 +17,21 @@ declare namespace astroHTML.JSX {
children: {};
}
interface IntrinsicAttributes
extends AstroBuiltinProps,
AstroBuiltinAttributes,
AstroClientDirectives {
interface IntrinsicAttributes extends AstroComponentDirectives, AstroBuiltinAttributes {
slot?: string | undefined | null;
children?: Children;
}
type AstroBuiltinProps = import('./dist/@types/astro.js').AstroBuiltinProps;
type AstroClientDirectives = import('./dist/@types/astro.js').AstroClientDirectives;
type AstroBuiltinAttributes = import('./dist/@types/astro.js').AstroBuiltinAttributes;
type AstroDefineVarsAttribute = import('./dist/@types/astro.js').AstroDefineVarsAttribute;
type AstroScriptAttributes = import('./dist/@types/astro.js').AstroScriptAttributes &
type AstroComponentDirectives =
import('./dist/types/public/elements.js').AstroComponentDirectives;
type AstroBuiltinAttributes = import('./dist/types/public/elements.js').AstroBuiltinAttributes;
type AstroDefineVarsAttribute =
import('./dist/types/public/elements.js').AstroDefineVarsAttribute;
type AstroScriptAttributes = import('./dist/types/public/elements.js').AstroScriptAttributes &
AstroDefineVarsAttribute;
type AstroStyleAttributes = import('./dist/@types/astro.js').AstroStyleAttributes &
type AstroStyleAttributes = import('./dist/types/public/elements.js').AstroStyleAttributes &
AstroDefineVarsAttribute;
type AstroSlotAttributes = import('./dist/@types/astro.js').AstroSlotAttributes;
type AstroSlotAttributes = import('./dist/types/public/elements.js').AstroSlotAttributes;
// This is an unfortunate use of `any`, but unfortunately we can't make a type that works for every framework
// without importing every single framework's types (which comes with its own set of problems).

View file

@ -2,12 +2,6 @@
/// <reference path="./types/content.d.ts" />
/// <reference path="./types/actions.d.ts" />
// eslint-disable-next-line @typescript-eslint/no-namespace
declare namespace App {
// eslint-disable-next-line @typescript-eslint/no-empty-interface
export interface Locals {}
}
interface ImportMetaEnv {
/**
* The prefix for Astro-generated asset links if the build.assetsPrefix config option is set. This can be used to create asset links not handled by Astro.
@ -52,7 +46,7 @@ declare module 'astro:assets' {
getImage: (
options: import('./dist/assets/types.js').UnresolvedImageTransform,
) => Promise<import('./dist/assets/types.js').GetImageResult>;
imageConfig: import('./dist/@types/astro.js').AstroConfig['image'];
imageConfig: import('./dist/types/public/config.js').AstroConfig['image'];
getConfiguredImageService: typeof import('./dist/assets/index.js').getConfiguredImageService;
inferRemoteSize: typeof import('./dist/assets/utils/index.js').inferRemoteSize;
Image: typeof import('./components/Image.astro').default;
@ -172,7 +166,7 @@ declare module 'astro:components' {
export * from 'astro/components';
}
type MD = import('./dist/@types/astro.js').MarkdownInstance<Record<string, any>>;
type MD = import('./dist/types/public/content.js').MarkdownInstance<Record<string, any>>;
interface ExportedMarkdownModuleEntities {
frontmatter: MD['frontmatter'];
file: MD['file'];
@ -191,7 +185,6 @@ declare module '*.md' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -206,7 +199,6 @@ declare module '*.markdown' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -221,7 +213,6 @@ declare module '*.mkdn' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -236,7 +227,6 @@ declare module '*.mkd' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -251,7 +241,6 @@ declare module '*.mdwn' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -266,7 +255,6 @@ declare module '*.mdown' {
file,
url,
getHeadings,
getHeaders,
Content,
rawContent,
compiledContent,
@ -275,7 +263,7 @@ declare module '*.mdown' {
}
declare module '*.mdx' {
type MDX = import('./dist/@types/astro.js').MDXInstance<Record<string, any>>;
type MDX = import('./dist/types/public/content.js').MDXInstance<Record<string, any>>;
export const frontmatter: MDX['frontmatter'];
export const file: MDX['file'];
@ -288,7 +276,7 @@ declare module '*.mdx' {
}
declare module 'astro:ssr-manifest' {
export const manifest: import('./dist/@types/astro.js').SSRManifest;
export const manifest: import('./dist/types/public/internal.js').SSRManifest;
}
// Everything below are Vite's types (apart from image types, which are in `client.d.ts`)

View file

@ -1,7 +1,7 @@
---
import { type LocalImageProps, type RemoteImageProps, getImage } from 'astro:assets';
import * as mime from 'mrmime';
import type { GetImageResult, ImageOutputFormat } from '../dist/@types/astro';
import type { GetImageResult, ImageOutputFormat } from '../dist/types/public/index.js';
import { isESMImportedImage, resolveSrc } from '../dist/assets/utils/imageKind';
import { AstroError, AstroErrorData } from '../dist/core/errors/index.js';
import type { HTMLAttributes } from '../types';

View file

@ -1,8 +1,8 @@
type ViteUserConfig = import('vite').UserConfig;
type ViteUserConfigFn = import('vite').UserConfigFn;
type AstroUserConfig = import('./dist/@types/astro.js').AstroUserConfig;
type AstroInlineConfig = import('./dist/@types/astro.js').AstroInlineConfig;
type ImageServiceConfig = import('./dist/@types/astro.js').ImageServiceConfig;
type AstroUserConfig = import('./dist/types/public/config.js').AstroUserConfig;
type AstroInlineConfig = import('./dist/types/public/config.js').AstroInlineConfig;
type ImageServiceConfig = import('./dist/types/public/config.js').ImageServiceConfig;
type SharpImageServiceConfig = import('./dist/assets/services/sharp.js').SharpImageServiceConfig;
type EnvField = typeof import('./dist/env/config.js').envField;
@ -42,4 +42,4 @@ export function passthroughImageService(): ImageServiceConfig;
/**
* Return a valid env field to use in this Astro config for `experimental.env.schema`.
*/
export const envField: EnvField;
export declare const envField: EnvField;

View file

@ -4,7 +4,7 @@
// As such, if the typings you're trying to add should be available inside ex: React components, they should instead
// be inside `client.d.ts`
type Astro = import('./dist/@types/astro.js').AstroGlobal;
type Astro = import('./dist/types/public/context.js').AstroGlobal;
// We have to duplicate the description here because editors won't show the JSDoc comment from the imported type
// However, they will for its properties, ex: Astro.request will show the AstroGlobal.request description

View file

@ -1,2 +1,2 @@
export type * from './dist/@types/astro.js';
export type * from './dist/types/public/index.js';
export * from './dist/core/index.js';

View file

@ -1,5 +0,0 @@
# `@types/`
TypeScript definitions and types for untyped modules.
[See CONTRIBUTING.md](../../../../CONTRIBUTING.md) for a code overview.

View file

@ -1,9 +0,0 @@
/**
* Shared interfaces throughout the application that can be overridden by the user.
*/
declare namespace App {
/**
* Used by middlewares to store information, that can be read by the user via the global `Astro.locals`
*/
interface Locals {}
}

View file

@ -1,9 +1,10 @@
import fsMod from 'node:fs';
import type { Plugin as VitePlugin } from 'vite';
import type { AstroIntegration, AstroSettings } from '../@types/astro.js';
import { ActionsWithoutServerOutputError } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/errors.js';
import { isServerLikeOutput, viteID } from '../core/util.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroIntegration } from '../types/public/integrations.js';
import {
ACTIONS_TYPES_FILE,
NOOP_ACTIONS,

View file

@ -1,8 +1,9 @@
import { yellow } from 'kleur/colors';
import type { APIContext, MiddlewareNext } from '../../@types/astro.js';
import { ActionQueryStringInvalidError } from '../../core/errors/errors-data.js';
import { AstroError } from '../../core/errors/errors.js';
import { defineMiddleware } from '../../core/middleware/index.js';
import type { MiddlewareNext } from '../../types/public/common.js';
import type { APIContext } from '../../types/public/context.js';
import { ACTION_QUERY_PARAMS } from '../consts.js';
import { formContentTypes, hasContentType } from './utils.js';
import { getAction } from './virtual/get-action.js';

View file

@ -1,4 +1,4 @@
import type { APIRoute } from '../../@types/astro.js';
import type { APIRoute } from '../../types/public/common.js';
import { formContentTypes, hasContentType } from './utils.js';
import { getAction } from './virtual/get-action.js';
import { serializeActionResult } from './virtual/shared.js';

View file

@ -1,4 +1,4 @@
import type { APIContext } from '../../@types/astro.js';
import type { APIContext } from '../../types/public/context.js';
export const formContentTypes = ['application/x-www-form-urlencoded', 'multipart/form-data'];

View file

@ -1,6 +1,6 @@
import type { APIContext } from '../@types/astro.js';
import type { APIContext } from '../types/public/context.js';
import type { Locals } from './runtime/middleware.js';
import { type ActionAPIContext } from './runtime/utils.js';
import type { ActionAPIContext } from './runtime/utils.js';
import { deserializeActionResult, getActionQueryString } from './runtime/virtual/shared.js';
export function hasActionPayload(locals: APIContext['locals']): locals is Locals {

View file

@ -2,7 +2,6 @@ import fs, { readFileSync } from 'node:fs';
import { basename } from 'node:path/posix';
import { dim, green } from 'kleur/colors';
import type PQueue from 'p-queue';
import type { AstroConfig } from '../../@types/astro.js';
import { getOutDirWithinCwd } from '../../core/build/common.js';
import type { BuildPipeline } from '../../core/build/pipeline.js';
import { getTimeStat } from '../../core/build/util.js';
@ -12,6 +11,7 @@ import type { Logger } from '../../core/logger/core.js';
import { isRemotePath, removeLeadingForwardSlash } from '../../core/path.js';
import { isServerLikeOutput } from '../../core/util.js';
import type { MapValue } from '../../type-utils.js';
import type { AstroConfig } from '../../types/public/config.js';
import { getConfiguredImageService } from '../internal.js';
import type { LocalImageService } from '../services/service.js';
import type { AssetsGlobalStaticImagesList, ImageMetadata, ImageTransform } from '../types.js';

View file

@ -1,4 +1,4 @@
import type { AstroSettings } from '../../@types/astro.js';
import type { AstroSettings } from '../../types/astro.js';
export function injectImageEndpoint(settings: AstroSettings, mode: 'dev' | 'build') {
const endpointEntrypoint =

View file

@ -2,7 +2,7 @@
import { imageConfig } from 'astro:assets';
import { isRemotePath } from '@astrojs/internal-helpers/path';
import * as mime from 'mrmime';
import type { APIRoute } from '../../@types/astro.js';
import type { APIRoute } from '../../types/public/common.js';
import { getConfiguredImageService } from '../internal.js';
import { etag } from '../utils/etag.js';
import { isRemoteAllowed } from '../utils/remotePattern.js';

View file

@ -7,7 +7,7 @@ import { fileURLToPath, pathToFileURL } from 'node:url';
import { assetsDir, imageConfig, outDir } from 'astro:assets';
import { isRemotePath, removeQueryString } from '@astrojs/internal-helpers/path';
import * as mime from 'mrmime';
import type { APIRoute } from '../../@types/astro.js';
import type { APIRoute } from '../../types/public/common.js';
import { getConfiguredImageService } from '../internal.js';
import { etag } from '../utils/etag.js';
import { isRemoteAllowed } from '../utils/remotePattern.js';

View file

@ -1,5 +1,5 @@
import type { AstroConfig } from '../@types/astro.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import type { AstroConfig } from '../types/public/config.js';
import { DEFAULT_HASH_PROPS } from './consts.js';
import { type ImageService, isLocalService } from './services/service.js';
import {

View file

@ -1,6 +1,6 @@
import type { AstroConfig } from '../../@types/astro.js';
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import { isRemotePath, joinPaths } from '../../core/path.js';
import type { AstroConfig } from '../../types/public/config.js';
import { DEFAULT_HASH_PROPS, DEFAULT_OUTPUT_FORMAT, VALID_SUPPORTED_FORMATS } from '../consts.js';
import type { ImageOutputFormat, ImageTransform, UnresolvedSrcSetValue } from '../types.js';
import { isESMImportedImage } from '../utils/imageKind.js';

View file

@ -1,5 +1,5 @@
import { isRemotePath } from '@astrojs/internal-helpers/path';
import type { AstroConfig } from '../../@types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
export type RemotePattern = {
hostname?: string;

View file

@ -2,7 +2,6 @@ import { extname } from 'node:path';
import MagicString from 'magic-string';
import type * as vite from 'vite';
import { normalizePath } from 'vite';
import type { AstroPluginOptions, AstroSettings, ImageTransform } from '../@types/astro.js';
import { extendManualChunks } from '../core/build/plugins/util.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import {
@ -13,7 +12,9 @@ import {
removeQueryString,
} from '../core/path.js';
import { isServerLikeOutput } from '../core/util.js';
import type { AstroPluginOptions, AstroSettings } from '../types/astro.js';
import { VALID_INPUT_FORMATS, VIRTUAL_MODULE_ID, VIRTUAL_SERVICE_ID } from './consts.js';
import type { ImageTransform } from './types.js';
import { getAssetsPrefix } from './utils/getAssetsPrefix.js';
import { isESMImportedImage } from './utils/imageKind.js';
import { emitESMImage } from './utils/node/emitAsset.js';

View file

@ -1,5 +1,5 @@
import type { Arguments } from 'yargs-parser';
import type { AstroConfig } from '../../@types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
import { resolveConfig } from '../../core/config/config.js';
import { apply as applyPolyfill } from '../../core/polyfill.js';
import { createLoggerFromFlags, flagsToAstroInlineConfig } from '../flags.js';

View file

@ -1,7 +1,7 @@
import type { Arguments } from 'yargs-parser';
import type { AstroInlineConfig } from '../@types/astro.js';
import { type LogOptions, Logger } from '../core/logger/core.js';
import { nodeLogDestination } from '../core/logger/node.js';
import type { AstroInlineConfig } from '../types/public/config.js';
// Alias for now, but allows easier migration to node's `parseArgs` in the future.
export type Flags = Arguments;

View file

@ -3,10 +3,10 @@ import { arch, platform } from 'node:os';
/* eslint-disable no-console */
import * as colors from 'kleur/colors';
import prompts from 'prompts';
import type { AstroConfig, AstroUserConfig } from '../../@types/astro.js';
import { resolveConfig } from '../../core/config/index.js';
import { ASTRO_VERSION } from '../../core/constants.js';
import { apply as applyPolyfill } from '../../core/polyfill.js';
import type { AstroConfig, AstroUserConfig } from '../../types/public/config.js';
import { type Flags, flagsToAstroInlineConfig } from '../flags.js';
interface InfoOptions {

View file

@ -1,5 +1,5 @@
/* eslint-disable no-console */
import type { AstroSettings } from '../../@types/astro.js';
import type { AstroSettings } from '../../types/astro.js';
import { fileURLToPath } from 'node:url';
import { bgGreen, black, bold, dim, yellow } from 'kleur/colors';

View file

@ -1,6 +1,6 @@
import type { UserConfig as ViteUserConfig } from 'vite';
import type { AstroInlineConfig, AstroUserConfig } from '../@types/astro.js';
import { Logger } from '../core/logger/core.js';
import type { AstroInlineConfig, AstroUserConfig } from '../types/public/config.js';
export function defineConfig(config: AstroUserConfig) {
return config;

View file

@ -1,8 +1,8 @@
import type fsMod from 'node:fs';
import type { Plugin, ViteDevServer } from 'vite';
import type { AstroSettings } from '../@types/astro.js';
import { attachContentServerListeners } from '../content/server-listeners.js';
import type { Logger } from '../core/logger/core.js';
import type { AstroSettings } from '../types/astro.js';
/**
* Listen for Astro content directory changes and generate types.

View file

@ -1,19 +1,4 @@
import { posix } from 'node:path';
import type {
AstroConfig,
AstroUserConfig,
ComponentInstance,
ContainerImportRendererFn,
MiddlewareHandler,
NamedSSRLoadedRendererValue,
Props,
RouteData,
RouteType,
SSRLoadedRenderer,
SSRLoadedRendererValue,
SSRManifest,
SSRResult,
} from '../@types/astro.js';
import { getDefaultClientDirectives } from '../core/client-directive/index.js';
import { ASTRO_CONFIG_DEFAULTS } from '../core/config/schema.js';
import { validateConfig } from '../core/config/validate.js';
@ -25,8 +10,32 @@ import { RenderContext } from '../core/render-context.js';
import { getParts, validateSegment } from '../core/routing/manifest/create.js';
import { getPattern } from '../core/routing/manifest/pattern.js';
import type { AstroComponentFactory } from '../runtime/server/index.js';
import type { ComponentInstance } from '../types/astro.js';
import type { MiddlewareHandler, Props } from '../types/public/common.js';
import type { AstroConfig, AstroUserConfig } from '../types/public/config.js';
import type {
NamedSSRLoadedRendererValue,
RouteData,
RouteType,
SSRLoadedRenderer,
SSRLoadedRendererValue,
SSRManifest,
SSRResult,
} from '../types/public/internal.js';
import { ContainerPipeline } from './pipeline.js';
/** Public type, used for integrations to define a renderer for the container API */
export type ContainerRenderer = {
/**
* The name of the renderer.
*/
name: string;
/**
* The entrypoint that is used to render a component on the server
*/
serverEntrypoint: string;
};
/**
* Options to be passed when rendering a route
*/
@ -103,6 +112,10 @@ export type AddClientRenderer = {
entrypoint: string;
};
type ContainerImportRendererFn = (
containerRenderer: ContainerRenderer,
) => Promise<SSRLoadedRenderer>;
function createManifest(
manifest?: AstroContainerManifest,
renderers?: SSRLoadedRenderer[],

View file

@ -1,10 +1,3 @@
import type {
ComponentInstance,
RewritePayload,
RouteData,
SSRElement,
SSRResult,
} from '../@types/astro.js';
import { type HeadElements, Pipeline } from '../core/base-pipeline.js';
import type { SinglePageBuiltModule } from '../core/build/types.js';
import {
@ -12,6 +5,9 @@ import {
createStylesheetElementSet,
} from '../core/render/ssr-element.js';
import { findRouteToRewrite } from '../core/routing/rewrite.js';
import type { ComponentInstance } from '../types/astro.js';
import type { RewritePayload } from '../types/public/common.js';
import type { RouteData, SSRElement, SSRResult } from '../types/public/internal.js';
export class ContainerPipeline extends Pipeline {
/**

View file

@ -3,9 +3,9 @@ import { isAbsolute } from 'node:path';
import { fileURLToPath } from 'node:url';
import type { FSWatcher } from 'vite';
import xxhash from 'xxhash-wasm';
import type { AstroSettings } from '../@types/astro.js';
import { AstroUserError } from '../core/errors/errors.js';
import type { Logger } from '../core/logger/core.js';
import type { AstroSettings } from '../types/astro.js';
import {
ASSET_IMPORTS_FILE,
CONTENT_LAYER_TYPE,

View file

@ -4,7 +4,7 @@ import fastGlob from 'fast-glob';
import { bold, green } from 'kleur/colors';
import micromatch from 'micromatch';
import pLimit from 'p-limit';
import type { ContentEntryRenderFuction, ContentEntryType } from '../../@types/astro.js';
import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';
import type { RenderedContent } from '../data-store.js';
import { getContentEntryIdAndSlug, getEntryConfigByExtMap, posixRelative } from '../utils.js';
import type { Loader } from './types.js';
@ -69,7 +69,7 @@ export function glob(globOptions: GlobOptions): Loader {
load: async ({ settings, logger, watcher, parseData, store, generateDigest }) => {
const renderFunctionByContentType = new WeakMap<
ContentEntryType,
ContentEntryRenderFuction
ContentEntryRenderFunction
>();
const untouchedEntries = new Set(store.keys());
@ -131,7 +131,7 @@ export function glob(globOptions: GlobOptions): Loader {
if (entryType.getRenderFunction) {
let render = renderFunctionByContentType.get(entryType);
if (!render) {
render = await entryType.getRenderFunction(settings);
render = await entryType.getRenderFunction(settings.config);
// Cache the render function for this content type, so it can re-use parsers and other expensive setup
renderFunctionByContentType.set(entryType, render);
}

View file

@ -1,6 +1,7 @@
import type { FSWatcher } from 'vite';
import type { ZodSchema } from 'zod';
import type { AstroIntegrationLogger, AstroSettings } from '../../@types/astro.js';
import type { AstroIntegrationLogger } from '../../core/logger/core.js';
import type { AstroSettings } from '../../types/astro.js';
import type { MetaStore, ScopedDataStore } from '../mutable-data-store.js';
export interface ParseDataOptions<TData extends Record<string, unknown>> {

View file

@ -2,7 +2,7 @@ import type { MarkdownHeading } from '@astrojs/markdown-remark';
import { Traverse } from 'neotraverse/modern';
import pLimit from 'p-limit';
import { ZodIssueCode, z } from 'zod';
import type { GetImageResult, ImageMetadata } from '../@types/astro.js';
import type { GetImageResult, ImageMetadata } from '../assets/types.js';
import { imageSrcToImportId } from '../assets/utils/resolveImports.js';
import { AstroError, AstroErrorData, AstroUserError } from '../core/errors/index.js';
import { prependForwardSlash } from '../core/path.js';

View file

@ -3,10 +3,10 @@ import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import { bold, cyan, underline } from 'kleur/colors';
import type { ViteDevServer } from 'vite';
import type { AstroSettings } from '../@types/astro.js';
import { loadTSConfig } from '../core/config/tsconfig.js';
import type { Logger } from '../core/logger/core.js';
import { appendForwardSlash } from '../core/path.js';
import type { AstroSettings } from '../types/astro.js';
import { createContentTypesGenerator } from './types-generator.js';
import { type ContentPaths, getContentPaths, globalContentConfigObserver } from './utils.js';

View file

@ -7,11 +7,12 @@ import { type ViteDevServer, normalizePath } from 'vite';
import { type ZodSchema, z } from 'zod';
import { zodToJsonSchema } from 'zod-to-json-schema';
import { printNode, zodToTs } from 'zod-to-ts';
import type { AstroSettings, ContentEntryType } from '../@types/astro.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import { isRelativePath } from '../core/path.js';
import type { AstroSettings } from '../types/astro.js';
import type { ContentEntryType } from '../types/public/content.js';
import { CONTENT_LAYER_TYPE, CONTENT_TYPES_FILE, VIRTUAL_MODULE_ID } from './consts.js';
import {
type CollectionConfig,

View file

@ -7,15 +7,12 @@ import type { PluginContext } from 'rollup';
import { type ViteDevServer, normalizePath } from 'vite';
import xxhash from 'xxhash-wasm';
import { z } from 'zod';
import type {
AstroConfig,
AstroSettings,
ContentEntryType,
DataEntryType,
} from '../@types/astro.js';
import { AstroError, AstroErrorData, MarkdownError, errorMap } from '../core/errors/index.js';
import { isYAMLException } from '../core/errors/utils.js';
import type { Logger } from '../core/logger/core.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroConfig } from '../types/public/config.js';
import type { ContentEntryType, DataEntryType } from '../types/public/content.js';
import {
CONTENT_FLAGS,
CONTENT_LAYER_TYPE,

View file

@ -1,7 +1,6 @@
import { extname } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { Plugin } from 'vite';
import type { AstroSettings, SSRElement } from '../@types/astro.js';
import { getAssetsPrefix } from '../assets/utils/getAssetsPrefix.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { AstroBuildPlugin } from '../core/build/plugin.js';
@ -9,6 +8,8 @@ import type { StaticBuildOptions } from '../core/build/types.js';
import type { ModuleLoader } from '../core/module-loader/loader.js';
import { createViteLoader } from '../core/module-loader/vite.js';
import { joinPaths, prependForwardSlash } from '../core/path.js';
import type { AstroSettings } from '../types/astro.js';
import type { SSRElement } from '../types/public/internal.js';
import { getStylesForURL } from '../vite-plugin-astro-server/css.js';
import { getScriptsForURL } from '../vite-plugin-astro-server/scripts.js';
import {

View file

@ -4,19 +4,19 @@ import { pathToFileURL } from 'node:url';
import * as devalue from 'devalue';
import type { PluginContext } from 'rollup';
import type { Plugin } from 'vite';
import type {
AstroConfig,
AstroSettings,
ContentEntryModule,
ContentEntryType,
DataEntryModule,
DataEntryType,
} from '../@types/astro.js';
import { getProxyCode } from '../assets/utils/proxy.js';
import { AstroError } from '../core/errors/errors.js';
import { AstroErrorData } from '../core/errors/index.js';
import type { Logger } from '../core/logger/core.js';
import { isServerLikeOutput } from '../core/util.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroConfig } from '../types/public/config.js';
import type {
ContentEntryModule,
ContentEntryType,
DataEntryModule,
DataEntryType,
} from '../types/public/content.js';
import { CONTENT_FLAG, DATA_FLAG } from './consts.js';
import {
type ContentConfig,

View file

@ -5,12 +5,12 @@ import { dataToEsm } from '@rollup/pluginutils';
import glob from 'fast-glob';
import pLimit from 'p-limit';
import type { Plugin } from 'vite';
import type { AstroSettings } from '../@types/astro.js';
import { encodeName } from '../core/build/util.js';
import { AstroError, AstroErrorData } from '../core/errors/index.js';
import { appendForwardSlash, removeFileExtension } from '../core/path.js';
import { isServerLikeOutput } from '../core/util.js';
import { rootRelativePath } from '../core/viteUtils.js';
import type { AstroSettings } from '../types/astro.js';
import type { AstroPluginMetadata } from '../vite-plugin-astro/index.js';
import { createDefaultAstroMetadata } from '../vite-plugin-astro/metadata.js';
import {

View file

@ -1,5 +1,6 @@
import type { ManifestData, RouteData, SSRManifest } from '../../@types/astro.js';
import { normalizeTheLocale } from '../../i18n/index.js';
import type { ManifestData } from '../../types/astro.js';
import type { RouteData, SSRManifest } from '../../types/public/internal.js';
import {
REROUTABLE_STATUS_CODES,
REROUTE_DIRECTIVE_HEADER,

View file

@ -1,4 +1,4 @@
import type { MiddlewareHandler } from '../../@types/astro.js';
import type { MiddlewareHandler } from '../../types/public/common.js';
import { defineMiddleware } from '../middleware/index.js';
/**

View file

@ -1,6 +1,6 @@
import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
import type { RouteData } from '../../@types/astro.js';
import type { RouteData } from '../../types/public/internal.js';
import { deserializeManifest } from './common.js';
import { createOutgoingHttpHeaders } from './createOutgoingHttpHeaders.js';
import { App } from './index.js';

View file

@ -1,11 +1,6 @@
import type {
ComponentInstance,
ManifestData,
RewritePayload,
RouteData,
SSRElement,
SSRResult,
} from '../../@types/astro.js';
import type { ComponentInstance, ManifestData } from '../../types/astro.js';
import type { RewritePayload } from '../../types/public/common.js';
import type { RouteData, SSRElement, SSRResult } from '../../types/public/internal.js';
import { Pipeline } from '../base-pipeline.js';
import type { SinglePageBuiltModule } from '../build/types.js';
import { RedirectSinglePageBuiltModule } from '../redirects/component.js';

View file

@ -1,14 +1,13 @@
import type { RoutingStrategies } from '../../i18n/utils.js';
import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
import type { MiddlewareHandler } from '../../types/public/common.js';
import type { Locales } from '../../types/public/config.js';
import type {
ComponentInstance,
Locales,
MiddlewareHandler,
RouteData,
SSRComponentMetadata,
SSRLoadedRenderer,
SSRResult,
SerializedRouteData,
} from '../../@types/astro.js';
import type { RoutingStrategies } from '../../i18n/utils.js';
} from '../../types/public/internal.js';
import type { SinglePageBuiltModule } from '../build/types.js';
export type ComponentPath = string;
@ -82,6 +81,7 @@ export type SSRManifestI18n = {
domainLookupTable: Record<string, string>;
};
/** Public type exposed through the `astro:build:ssr` integration hook */
export type SerializedSSRManifest = Omit<
SSRManifest,
| 'middleware'

View file

@ -1,15 +1,14 @@
import { setGetEnv } from '../env/runtime.js';
import { createI18nMiddleware } from '../i18n/middleware.js';
import type { ComponentInstance } from '../types/astro.js';
import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
import type { RuntimeMode } from '../types/public/config.js';
import type {
ComponentInstance,
MiddlewareHandler,
RewritePayload,
RouteData,
RuntimeMode,
SSRLoadedRenderer,
SSRManifest,
SSRResult,
} from '../@types/astro.js';
import { setGetEnv } from '../env/runtime.js';
import { createI18nMiddleware } from '../i18n/middleware.js';
} from '../types/public/internal.js';
import { AstroError } from './errors/errors.js';
import { AstroErrorData } from './errors/index.js';
import type { Logger } from './logger/core.js';

View file

@ -1,7 +1,8 @@
import npath from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroConfig, RouteData } from '../../@types/astro.js';
import { appendForwardSlash } from '../../core/path.js';
import type { AstroConfig } from '../../types/public/config.js';
import type { RouteData } from '../../types/public/internal.js';
const STATUS_CODE_PAGES = new Set(['/404', '/500']);
const FALLBACK_OUT_DIR_NAME = './.astro/';

View file

@ -4,7 +4,7 @@ import crypto from 'node:crypto';
import npath from 'node:path';
import { fileURLToPath } from 'node:url';
import { normalizePath } from 'vite';
import type { AstroSettings } from '../../@types/astro.js';
import type { AstroSettings } from '../../types/astro.js';
import { viteID } from '../util.js';
import { getTopLevelPageModuleInfos } from './graph.js';

View file

@ -2,18 +2,6 @@ import fs from 'node:fs';
import os from 'node:os';
import { bgGreen, black, blue, bold, dim, green, magenta, red } from 'kleur/colors';
import PQueue from 'p-queue';
import type {
AstroConfig,
AstroSettings,
ComponentInstance,
GetStaticPathsItem,
MiddlewareHandler,
RouteData,
RouteType,
SSRError,
SSRLoadedRenderer,
SSRManifest,
} from '../../@types/astro.js';
import {
generateImagesForPath,
getStaticImageList,
@ -29,7 +17,16 @@ import {
import { toRoutingStrategy } from '../../i18n/utils.js';
import { runHookBuildGenerated } from '../../integrations/hooks.js';
import { getOutputDirectory } from '../../prerender/utils.js';
import type { SSRManifestI18n } from '../app/types.js';
import type { AstroSettings, ComponentInstance } from '../../types/astro.js';
import type { GetStaticPathsItem, MiddlewareHandler } from '../../types/public/common.js';
import type { AstroConfig } from '../../types/public/config.js';
import type {
RouteData,
RouteType,
SSRError,
SSRLoadedRenderer,
} from '../../types/public/internal.js';
import type { SSRManifest, SSRManifestI18n } from '../app/types.js';
import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { getRedirectLocationOrThrow, routeIsRedirect } from '../redirects/index.js';

View file

@ -3,13 +3,6 @@ import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import { blue, bold, green } from 'kleur/colors';
import type * as vite from 'vite';
import type {
AstroConfig,
AstroInlineConfig,
AstroSettings,
ManifestData,
RuntimeMode,
} from '../../@types/astro.js';
import { injectImageEndpoint } from '../../assets/endpoint/config.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
@ -19,6 +12,8 @@ import {
runHookConfigDone,
runHookConfigSetup,
} from '../../integrations/hooks.js';
import type { AstroSettings, ManifestData } from '../../types/astro.js';
import type { AstroConfig, AstroInlineConfig, RuntimeMode } from '../../types/public/config.js';
import { resolveConfig } from '../config/config.js';
import { createNodeLogger } from '../config/logging.js';
import { createSettings } from '../config/settings.js';

View file

@ -1,5 +1,5 @@
import type { Rollup } from 'vite';
import type { RouteData, SSRResult } from '../../@types/astro.js';
import type { RouteData, SSRResult } from '../../types/public/internal.js';
import { prependForwardSlash, removeFileExtension } from '../path.js';
import { viteID } from '../util.js';
import { makePageDataKey } from './plugins/util.js';

View file

@ -1,4 +1,4 @@
import type { AstroSettings, ManifestData } from '../../@types/astro.js';
import type { AstroSettings, ManifestData } from '../../types/astro.js';
import type { Logger } from '../logger/core.js';
import type { AllPagesData } from './types.js';

View file

@ -1,11 +1,7 @@
import type {
ComponentInstance,
RewritePayload,
RouteData,
SSRLoadedRenderer,
SSRResult,
} from '../../@types/astro.js';
import { getOutputDirectory } from '../../prerender/utils.js';
import type { ComponentInstance } from '../../types/astro.js';
import type { RewritePayload } from '../../types/public/common.js';
import type { RouteData, SSRLoadedRenderer, SSRResult } from '../../types/public/internal.js';
import { BEFORE_HYDRATION_SCRIPT_ID, PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import type { SSRManifest } from '../app/types.js';
import { routeIsFallback, routeIsRedirect } from '../redirects/helpers.js';

View file

@ -4,13 +4,13 @@ import { fileURLToPath } from 'node:url';
import glob from 'fast-glob';
import pLimit from 'p-limit';
import { type Plugin as VitePlugin, normalizePath } from 'vite';
import type { AstroConfig } from '../../../@types/astro.js';
import { CONTENT_RENDER_FLAG, PROPAGATED_ASSET_FLAG } from '../../../content/consts.js';
import { type ContentLookupMap, hasContentFlag } from '../../../content/utils.js';
import {
generateContentEntryFile,
generateLookupMap,
} from '../../../content/vite-plugin-content-virtual-mod.js';
import type { AstroConfig } from '../../../types/public/config.js';
import { configPaths } from '../../config/index.js';
import { emptyDir } from '../../fs/index.js';
import {

View file

@ -1,5 +1,5 @@
import type { BuildOptions, Rollup, Plugin as VitePlugin } from 'vite';
import type { AstroSettings } from '../../../@types/astro.js';
import type { AstroSettings } from '../../../types/astro.js';
import { viteID } from '../../util.js';
import type { BuildInternals } from '../internal.js';
import { getPageDataByViteID } from '../internal.js';

View file

@ -1,8 +1,9 @@
import { join } from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { Plugin as VitePlugin } from 'vite';
import type { AstroAdapter, AstroSettings } from '../../../@types/astro.js';
import { isFunctionPerRouteEnabled } from '../../../integrations/hooks.js';
import type { AstroSettings } from '../../../types/astro.js';
import type { AstroAdapter } from '../../../types/public/integrations.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { VIRTUAL_ISLAND_MAP_ID } from '../../server-islands/vite-plugin-server-islands.js';
import { isServerLikeOutput } from '../../util.js';

View file

@ -5,7 +5,6 @@ import { teardown } from '@astrojs/compiler';
import glob from 'fast-glob';
import { bgGreen, bgMagenta, black, green } from 'kleur/colors';
import * as vite from 'vite';
import type { RouteData } from '../../@types/astro.js';
import { PROPAGATED_ASSET_FLAG } from '../../content/consts.js';
import {
getSymlinkedContentCollections,
@ -22,6 +21,7 @@ import { appendForwardSlash, prependForwardSlash, removeFileExtension } from '..
import { isModeServerWithNoAdapter, isServerLikeOutput } from '../../core/util.js';
import { runHookBuildSetup } from '../../integrations/hooks.js';
import { getOutputDirectory } from '../../prerender/utils.js';
import type { RouteData } from '../../types/public/internal.js';
import { PAGE_SCRIPT_ID } from '../../vite-plugin-scripts/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';

View file

@ -1,14 +1,9 @@
import type * as vite from 'vite';
import type { InlineConfig } from 'vite';
import type {
AstroSettings,
ComponentInstance,
ManifestData,
MiddlewareHandler,
RouteData,
RuntimeMode,
SSRLoadedRenderer,
} from '../../@types/astro.js';
import type { AstroSettings, ComponentInstance, ManifestData } from '../../types/astro.js';
import type { MiddlewareHandler } from '../../types/public/common.js';
import type { RuntimeMode } from '../../types/public/config.js';
import type { RouteData, SSRLoadedRenderer } from '../../types/public/internal.js';
import type { Logger } from '../logger/core.js';
export type ComponentPath = string;
@ -20,6 +15,7 @@ export type StylesheetAsset =
export type HoistedScriptAsset = { type: 'inline' | 'external'; value: string };
/** Public type exposed through the `astro:build:setup` integration hook */
export interface PageBuildData {
key: string;
component: ComponentPath;

View file

@ -1,5 +1,5 @@
import type { Rollup } from 'vite';
import type { AstroConfig } from '../../@types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
import type { ViteBuildReturn } from './types.js';
export function getTimeStat(timeStart: number, timeEnd: number) {

View file

@ -1,11 +1,11 @@
import type { TransformResult } from '@astrojs/compiler';
import type { ResolvedConfig } from 'vite';
import type { AstroConfig } from '../../@types/astro.js';
import { fileURLToPath } from 'node:url';
import { transform } from '@astrojs/compiler';
import { normalizePath } from 'vite';
import type { AstroPreferences } from '../../preferences/index.js';
import type { AstroConfig } from '../../types/public/config.js';
import type { AstroError } from '../errors/errors.js';
import { AggregateError, CompilerError } from '../errors/errors.js';
import { AstroErrorData } from '../errors/index.js';

View file

@ -3,13 +3,13 @@ import path from 'node:path';
import { fileURLToPath } from 'node:url';
import * as colors from 'kleur/colors';
import { ZodError } from 'zod';
import { eventConfigError, telemetry } from '../../events/index.js';
import type {
AstroConfig,
AstroInlineConfig,
AstroInlineOnlyConfig,
AstroUserConfig,
} from '../../@types/astro.js';
import { eventConfigError, telemetry } from '../../events/index.js';
} from '../../types/public/config.js';
import { trackAstroConfigZodError } from '../errors/errors.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import { formatConfigErrorMessage } from '../messages.js';

View file

@ -1,4 +1,4 @@
import type { AstroInlineConfig } from '../../@types/astro.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import { Logger } from '../logger/core.js';
import { nodeLogDestination } from '../logger/node.js';

View file

@ -6,13 +6,13 @@ import type {
} from '@astrojs/markdown-remark';
import { markdownConfigDefaults } from '@astrojs/markdown-remark';
import { type BuiltinTheme, bundledThemes } from 'shiki';
import type { AstroUserConfig, ViteUserConfig } from '../../@types/astro.js';
import type { OutgoingHttpHeaders } from 'node:http';
import path from 'node:path';
import { pathToFileURL } from 'node:url';
import { z } from 'zod';
import { EnvSchema } from '../../env/schema.js';
import type { AstroUserConfig, ViteUserConfig } from '../../types/public/config.js';
import { appendForwardSlash, prependForwardSlash, removeTrailingForwardSlash } from '../path.js';
// The below types are required boilerplate to workaround a Zod issue since v3.21.2. Since that version,

View file

@ -1,9 +1,10 @@
import path from 'node:path';
import { fileURLToPath, pathToFileURL } from 'node:url';
import yaml from 'js-yaml';
import type { AstroConfig, AstroSettings } from '../../@types/astro.js';
import { getContentPaths } from '../../content/index.js';
import createPreferences from '../../preferences/index.js';
import type { AstroSettings } from '../../types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
import { markdownContentEntryType } from '../../vite-plugin-markdown/content-entry-type.js';
import { getDefaultClientDirectives } from '../client-directive/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';

View file

@ -1,4 +1,4 @@
import type { AstroConfig } from '../../@types/astro.js';
import type { AstroConfig } from '../../types/public/config.js';
import { createRelativeSchema } from './schema.js';
/** Turn raw config values into normalized values */

View file

@ -3,7 +3,6 @@ import { fileURLToPath } from 'node:url';
import glob from 'fast-glob';
import * as vite from 'vite';
import { crawlFrameworkPkgs } from 'vitefu';
import type { AstroSettings } from '../@types/astro.js';
import { getAssetsPrefix } from '../assets/utils/getAssetsPrefix.js';
import astroAssetsPlugin from '../assets/vite-plugin-assets.js';
import astroContainer from '../container/vite-plugin-container.js';
@ -17,6 +16,7 @@ import astroInternationalization from '../i18n/vite-plugin-i18n.js';
import astroPrefetch from '../prefetch/vite-plugin-prefetch.js';
import astroDevToolbar from '../toolbar/vite-plugin-dev-toolbar.js';
import astroTransitions from '../transitions/vite-plugin-transitions.js';
import type { AstroSettings } from '../types/astro.js';
import astroPostprocessVitePlugin from '../vite-plugin-astro-postprocess/index.js';
import { vitePluginAstroServer } from '../vite-plugin-astro-server/index.js';
import astroVitePlugin from '../vite-plugin-astro/index.js';
@ -185,7 +185,7 @@ export async function createVite(
{
// Typings are imported from 'astro' (e.g. import { Type } from 'astro')
find: /^astro$/,
replacement: fileURLToPath(new URL('../@types/astro.js', import.meta.url)),
replacement: fileURLToPath(new URL('../types/public/index.js', import.meta.url)),
},
{
find: 'astro:middleware',

View file

@ -1,6 +1,6 @@
import type * as http from 'node:http';
import type { AddressInfo } from 'node:net';
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
import type { AstroSettings } from '../../types/astro.js';
import nodeFs from 'node:fs';
import * as vite from 'vite';
@ -11,6 +11,7 @@ import {
runHookServerDone,
runHookServerStart,
} from '../../integrations/hooks.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import { createVite } from '../create-vite.js';
import type { Logger } from '../logger/core.js';
import { apply as applyPolyfill } from '../polyfill.js';

View file

@ -5,13 +5,13 @@ import { performance } from 'node:perf_hooks';
import { green } from 'kleur/colors';
import { gt, major, minor, patch } from 'semver';
import type * as vite from 'vite';
import type { AstroInlineConfig } from '../../@types/astro.js';
import { DATA_STORE_FILE } from '../../content/consts.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { attachContentServerListeners } from '../../content/index.js';
import { MutableDataStore } from '../../content/mutable-data-store.js';
import { globalContentConfigObserver } from '../../content/utils.js';
import { telemetry } from '../../events/index.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import * as msg from '../messages.js';
import { ensureProcessNodeEnv } from '../util.js';
import { startContainer } from './container.js';

View file

@ -1,9 +1,10 @@
import type nodeFs from 'node:fs';
import { fileURLToPath } from 'node:url';
import * as vite from 'vite';
import type { AstroInlineConfig, AstroSettings } from '../../@types/astro.js';
import { globalContentLayer } from '../../content/content-layer.js';
import { eventCliSession, telemetry } from '../../events/index.js';
import type { AstroSettings } from '../../types/astro.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import { createNodeLogger, createSettings, resolveConfig } from '../config/index.js';
import { collectErrorMetadata } from '../errors/dev/utils.js';
import { isAstroConfigZodError } from '../errors/errors.js';

View file

@ -6,7 +6,7 @@ import { bold, underline } from 'kleur/colors';
import stripAnsi from 'strip-ansi';
import type { ESBuildTransformResult } from 'vite';
import { normalizePath } from 'vite';
import type { SSRError } from '../../../@types/astro.js';
import type { SSRError } from '../../../types/public/internal.js';
import { removeLeadingForwardSlashWindows } from '../../path.js';
import { AggregateError, type ErrorWithMetadata } from '../errors.js';
import { AstroErrorData } from '../index.js';

View file

@ -3,11 +3,11 @@ import { fileURLToPath } from 'node:url';
import { codeToHtml, createCssVariablesTheme } from 'shiki';
import type { ShikiTransformer } from 'shiki';
import type { ErrorPayload } from 'vite';
import type { SSRLoadedRenderer } from '../../../types/public/internal.js';
import type { ModuleLoader } from '../../module-loader/index.js';
import { FailedToLoadModuleSSR, InvalidGlob, MdxIntegrationMissingError } from '../errors-data.js';
import { AstroError, type ErrorWithMetadata } from '../errors.js';
import { createSafeError } from '../utils.js';
import type { SSRLoadedRenderer } from './../../../@types/astro.js';
import { getDocsForError, renderErrorMarkdown } from './utils.js';
export function enhanceViteSSRError({

View file

@ -1,5 +1,5 @@
// BEFORE ADDING AN ERROR: Please look at the README.md in this folder for general guidelines on writing error messages
// Additionally, this code, much like `@types/astro.ts`, is used to generate documentation, so make sure to pass
// Additionally, this code, much like `types/public/config.ts`, is used to generate documentation, so make sure to pass
// your changes by our wonderful docs team before merging!
import type { ZodError } from 'zod';

View file

@ -1,6 +1,6 @@
import type { YAMLException } from 'js-yaml';
import type { ErrorPayload as ViteErrorPayload } from 'vite';
import type { SSRError } from '../../@types/astro.js';
import type { SSRError } from '../../types/public/internal.js';
/**
* Get the line and character based on the offset

View file

@ -1,6 +1,6 @@
// This is the main entrypoint when importing the `astro` package.
import type { AstroInlineConfig } from '../@types/astro.js';
import type { AstroInlineConfig } from '../types/public/config.js';
import { default as _build } from './build/index.js';
import { default as _sync } from './sync/index.js';

View file

@ -1,9 +1,9 @@
import type {
APIContext,
MiddlewareHandler,
MiddlewareNext,
RewritePayload,
} from '../../@types/astro.js';
} from '../../types/public/common.js';
import type { APIContext } from '../../types/public/context.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
/**

View file

@ -1,10 +1,11 @@
import type { APIContext, MiddlewareHandler, Params, RewritePayload } from '../../@types/astro.js';
import { createCallAction, createGetActionResult } from '../../actions/utils.js';
import {
computeCurrentLocale,
computePreferredLocale,
computePreferredLocaleList,
} from '../../i18n/utils.js';
import type { MiddlewareHandler, Params, RewritePayload } from '../../types/public/common.js';
import type { APIContext } from '../../types/public/context.js';
import { ASTRO_VERSION, clientAddressSymbol, clientLocalsSymbol } from '../constants.js';
import { AstroCookies } from '../cookies/index.js';
import { AstroError, AstroErrorData } from '../errors/index.js';

View file

@ -1,4 +1,5 @@
import type { APIContext, MiddlewareHandler, RewritePayload } from '../../@types/astro.js';
import type { MiddlewareHandler, RewritePayload } from '../../types/public/common.js';
import type { APIContext } from '../../types/public/context.js';
import { AstroCookies } from '../cookies/cookies.js';
import { defineMiddleware } from './index.js';

View file

@ -1,7 +1,7 @@
import type { Plugin as VitePlugin } from 'vite';
import { normalizePath } from 'vite';
import type { AstroSettings } from '../../@types/astro.js';
import { getOutputDirectory } from '../../prerender/utils.js';
import type { AstroSettings } from '../../types/astro.js';
import { addRollupInput } from '../build/add-rollup-input.js';
import type { BuildInternals } from '../build/internal.js';
import type { StaticBuildOptions } from '../build/types.js';

View file

@ -1,6 +1,6 @@
import { EventEmitter } from 'node:events';
import type * as fs from 'node:fs';
import type { TypedEventEmitter } from '../../@types/typed-emitter.js';
import type { TypedEventEmitter } from '../../types/typed-emitter.js';
// This is a generic interface for a module loader. In the astro cli this is
// fulfilled by Vite, see vite.ts

View file

@ -1,11 +1,12 @@
import fs from 'node:fs';
import { createRequire } from 'node:module';
import { fileURLToPath, pathToFileURL } from 'node:url';
import type { AstroInlineConfig, PreviewModule, PreviewServer } from '../../@types/astro.js';
import { AstroIntegrationLogger } from '../../core/logger/core.js';
import { telemetry } from '../../events/index.js';
import { eventCliSession } from '../../events/session.js';
import { runHookConfigDone, runHookConfigSetup } from '../../integrations/hooks.js';
import type { AstroInlineConfig } from '../../types/public/config.js';
import type { PreviewModule, PreviewServer } from '../../types/public/preview.js';
import { resolveConfig } from '../config/config.js';
import { createNodeLogger } from '../config/logging.js';
import { createSettings } from '../config/settings.js';

View file

@ -2,7 +2,7 @@ import type http from 'node:http';
import { performance } from 'node:perf_hooks';
import { fileURLToPath } from 'node:url';
import { type PreviewServer as VitePreviewServer, preview } from 'vite';
import type { AstroSettings } from '../../@types/astro.js';
import type { AstroSettings } from '../../types/astro.js';
import type { Logger } from '../logger/core.js';
import * as msg from '../messages.js';
import { getResolvedHostForHttpServer } from './util.js';

View file

@ -2,8 +2,8 @@ import fs from 'node:fs';
import type { IncomingMessage, ServerResponse } from 'node:http';
import { fileURLToPath } from 'node:url';
import type { Connect, Plugin } from 'vite';
import type { AstroSettings } from '../../@types/astro.js';
import { notFoundTemplate, subpathNotUsedTemplate } from '../../template/4xx.js';
import type { AstroSettings } from '../../types/astro.js';
import { cleanUrl } from '../../vite-plugin-utils/index.js';
import { stripBase } from './util.js';

View file

@ -1,4 +1,4 @@
import type { ComponentInstance } from '../../@types/astro.js';
import type { ComponentInstance } from '../../types/astro.js';
import type { SinglePageBuiltModule } from '../build/types.js';
// A stub of a component instance for a given route

View file

@ -1,4 +1,8 @@
import type { RedirectRouteData, RouteData } from '../../@types/astro.js';
import type { RouteData } from '../../types/public/internal.js';
type RedirectRouteData = RouteData & {
redirect: string;
};
export function routeIsRedirect(route: RouteData | undefined): route is RedirectRouteData {
return route?.type === 'redirect';

View file

@ -1,14 +1,3 @@
import type {
APIContext,
AstroGlobal,
AstroGlobalPartial,
ComponentInstance,
MiddlewareHandler,
Props,
RewritePayload,
RouteData,
SSRResult,
} from '../@types/astro.js';
import type { ActionAPIContext } from '../actions/runtime/utils.js';
import { deserializeActionResult } from '../actions/runtime/virtual/shared.js';
import { createCallAction, createGetActionResult, hasActionPayload } from '../actions/utils.js';
@ -19,6 +8,10 @@ import {
} from '../i18n/utils.js';
import { renderEndpoint } from '../runtime/server/endpoint.js';
import { renderPage } from '../runtime/server/index.js';
import type { ComponentInstance } from '../types/astro.js';
import type { MiddlewareHandler, Props, RewritePayload } from '../types/public/common.js';
import type { APIContext, AstroGlobal, AstroGlobalPartial } from '../types/public/context.js';
import type { RouteData, SSRResult } from '../types/public/internal.js';
import {
ASTRO_VERSION,
REROUTE_DIRECTIVE_HEADER,

View file

@ -1,4 +1,5 @@
import type { ComponentInstance, RouteData } from '../../@types/astro.js';
import type { ComponentInstance } from '../../types/astro.js';
import type { RouteData } from '../../types/public/internal.js';
import type { Pipeline } from '../base-pipeline.js';
export { Pipeline } from '../base-pipeline.js';
export { getParams, getProps } from './params-and-props.js';

View file

@ -4,8 +4,8 @@ import type {
PaginateOptions,
Params,
Props,
RouteData,
} from '../../@types/astro.js';
} from '../../types/public/common.js';
import type { RouteData } from '../../types/public/internal.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
export function generatePaginateFunction(

View file

@ -1,4 +1,6 @@
import type { ComponentInstance, Params, Props, RouteData } from '../../@types/astro.js';
import type { ComponentInstance } from '../../types/astro.js';
import type { Params, Props } from '../../types/public/common.js';
import type { RouteData } from '../../types/public/internal.js';
import { DEFAULT_404_COMPONENT } from '../constants.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';

View file

@ -1,4 +1,5 @@
import type { AstroRenderer, SSRLoadedRenderer } from '../../@types/astro.js';
import type { AstroRenderer } from '../../types/public/integrations.js';
import type { SSRLoadedRenderer } from '../../types/public/internal.js';
import type { ModuleLoader } from '../module-loader/index.js';
export async function loadRenderer(

View file

@ -1,13 +1,13 @@
import type { ComponentInstance } from '../../types/astro.js';
import type {
ComponentInstance,
GetStaticPathsItem,
GetStaticPathsResult,
GetStaticPathsResultKeyed,
PaginateFunction,
Params,
RouteData,
RuntimeMode,
} from '../../@types/astro.js';
} from '../../types/public/common.js';
import type { RuntimeMode } from '../../types/public/config.js';
import type { RouteData } from '../../types/public/internal.js';
import type { Logger } from '../logger/core.js';
import { stringifyParams } from '../routing/params.js';

View file

@ -1,8 +1,8 @@
import type { SSRResult } from '../../@types/astro.js';
import { type ComponentSlots, renderSlotToString } from '../../runtime/server/index.js';
import { renderJSX } from '../../runtime/server/jsx.js';
import { chunkToString } from '../../runtime/server/render/index.js';
import { isRenderInstruction } from '../../runtime/server/render/instruction.js';
import type { SSRResult } from '../../types/public/internal.js';
import { AstroError, AstroErrorData } from '../errors/index.js';
import type { Logger } from '../logger/core.js';

View file

@ -1,7 +1,7 @@
import type { AssetsPrefix, SSRElement } from '../../@types/astro.js';
import { getAssetsPrefix } from '../../assets/utils/getAssetsPrefix.js';
import { fileExtension, joinPaths, prependForwardSlash, slash } from '../../core/path.js';
import type { StylesheetAsset } from '../app/types.js';
import type { SSRElement } from '../../types/public/internal.js';
import type { AssetsPrefix, StylesheetAsset } from '../app/types.js';
export function createAssetLink(href: string, base?: string, assetsPrefix?: AssetsPrefix): string {
if (assetsPrefix) {

View file

@ -1,5 +1,6 @@
import type { ComponentInstance, ManifestData, RouteData } from '../../@types/astro.js';
import notFoundTemplate from '../../template/4xx.js';
import type { ComponentInstance, ManifestData } from '../../types/astro.js';
import type { RouteData } from '../../types/public/internal.js';
import { DEFAULT_404_COMPONENT, DEFAULT_500_COMPONENT } from '../constants.js';
export const DEFAULT_404_ROUTE: RouteData = {

View file

@ -1,4 +1,5 @@
import type { ComponentInstance, ManifestData, SSRManifest } from '../../@types/astro.js';
import type { ComponentInstance, ManifestData } from '../../types/astro.js';
import type { SSRManifest } from '../app/types.js';
import { DEFAULT_404_COMPONENT } from '../constants.js';
import {
SERVER_ISLAND_COMPONENT,

View file

@ -1,11 +1,4 @@
import type {
AstroConfig,
AstroSettings,
ManifestData,
RouteData,
RoutePart,
RoutePriorityOverride,
} from '../../../@types/astro.js';
import type { AstroSettings, ManifestData } from '../../../types/astro.js';
import type { Logger } from '../../logger/core.js';
import nodeFs from 'node:fs';
@ -15,6 +8,9 @@ import { fileURLToPath } from 'node:url';
import { bold } from 'kleur/colors';
import { toRoutingStrategy } from '../../../i18n/utils.js';
import { getPrerenderDefault } from '../../../prerender/utils.js';
import type { AstroConfig } from '../../../types/public/config.js';
import type { RoutePriorityOverride } from '../../../types/public/integrations.js';
import type { RouteData, RoutePart } from '../../../types/public/internal.js';
import { SUPPORTED_MARKDOWN_FILE_EXTENSIONS } from '../../constants.js';
import { MissingIndexForInternationalization } from '../../errors/errors-data.js';
import { AstroError } from '../../errors/index.js';

View file

@ -1,6 +1,6 @@
import type { AstroConfig, RoutePart } from '../../../@types/astro.js';
import { compile } from 'path-to-regexp';
import type { AstroConfig } from '../../../types/public/config.js';
import type { RoutePart } from '../../../types/public/internal.js';
/**
* Sanitizes the parameters object by normalizing string values and replacing certain characters with their URL-encoded equivalents.

Some files were not shown because too many files have changed in this diff Show more