Skip to content

Commit

Permalink
chore: organize imports
Browse files Browse the repository at this point in the history
  • Loading branch information
Princesseuh committed Aug 15, 2024
1 parent f286a0b commit 9279d56
Show file tree
Hide file tree
Showing 21 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion packages/astro/src/container/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ 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 { ContainerRenderer } from '../types/public/container.js';
import type {
NamedSSRLoadedRendererValue,
RouteData,
Expand All @@ -23,7 +24,6 @@ import type {
SSRResult,
} from '../types/public/internal.js';
import { ContainerPipeline } from './pipeline.js';
import type { ContainerRenderer } from '../types/public/container.js';

/**
* Options to be passed when rendering a route
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/loaders/glob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ import fastGlob from 'fast-glob';
import { bold, green } from 'kleur/colors';
import micromatch from 'micromatch';
import pLimit from 'p-limit';
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';
import type { ContentEntryRenderFunction, ContentEntryType } from '../../types/public/content.js';

export interface GenerateIdOptions {
/** The path to the entry file, relative to the base directory. */
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/types-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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,
Expand All @@ -28,7 +29,6 @@ import {
getEntryType,
reloadContentConfigObserver,
} from './utils.js';
import type { ContentEntryType } from '../types/public/content.js';

type ChokidarEvent = 'add' | 'addDir' | 'change' | 'unlink' | 'unlinkDir';
type RawContentEvent = { name: ChokidarEvent; entry: string };
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ 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,
Expand All @@ -20,7 +21,6 @@ import {
PROPAGATED_ASSET_FLAG,
} from './consts.js';
import { createImage } from './runtime-assets.js';
import type { ContentEntryType, DataEntryType } from '../types/public/content.js';
/**
* Amap from a collection + slug to the local file path.
* This is used internally to resolve entry imports when using `getEntry()`.
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/content/vite-plugin-content-assets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ 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 {
Expand All @@ -20,7 +21,6 @@ import {
STYLES_PLACEHOLDER,
} from './consts.js';
import { hasContentFlag } from './utils.js';
import type { SSRElement } from '../types/public/internal.js';

export function astroContentAssetPropagationPlugin({
mode,
Expand Down
12 changes: 6 additions & 6 deletions packages/astro/src/content/vite-plugin-content-imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ 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,
Expand All @@ -30,12 +36,6 @@ import {
reloadContentConfigObserver,
reverseSymlink,
} from './utils.js';
import type {
ContentEntryType,
DataEntryType,
ContentEntryModule,
DataEntryModule,
} from '../types/public/content.js';

function getContentRendererByViteId(
viteId: string,
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/generate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ import type { AstroConfig } from '../../types/public/config.js';
import type {
RouteData,
RouteType,
SSRLoadedRenderer,
SSRError,
SSRLoadedRenderer,
} from '../../types/public/internal.js';
import type { SSRManifest, SSRManifestI18n } from '../app/types.js';
import { NoPrerenderedRoutesWithDomains } from '../errors/errors-data.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/errors/dev/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ 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/public/internal.js';
import { removeLeadingForwardSlashWindows } from '../../path.js';
import { AggregateError, type ErrorWithMetadata } from '../errors.js';
import { AstroErrorData } from '../index.js';
import { codeFrame } from '../printer.js';
import { normalizeLF } from '../utils.js';
import type { SSRError } from '../../../types/public/internal.js';

type EsbuildMessage = ESBuildTransformResult['warnings'][number];

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/errors/dev/vite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ 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 { getDocsForError, renderErrorMarkdown } from './utils.js';
import type { SSRLoadedRenderer } from '../../../types/public/internal.js';

export function enhanceViteSSRError({
error,
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/i18n/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { appendForwardSlash, joinPaths } from '@astrojs/internal-helpers/path';
import type { SSRManifest } from '../core/app/types.js';
import { shouldAppendForwardSlash } from '../core/build/util.js';
import { REROUTE_DIRECTIVE_HEADER } from '../core/constants.js';
import { MissingLocale, i18nNoLocaleFoundInPath } from '../core/errors/errors-data.js';
Expand All @@ -7,7 +8,6 @@ import type { AstroConfig, Locales, ValidRedirectStatus } from '../types/public/
import type { APIContext } from '../types/public/context.js';
import { createI18nMiddleware } from './middleware.js';
import type { RoutingStrategies } from './utils.js';
import type { SSRManifest } from '../core/app/types.js';

export function requestHasLocale(locales: Locales) {
return function (context: APIContext): boolean {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/integrations/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import type { AstroIntegrationLogger, 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 { ContentEntryType, DataEntryType } from '../types/public/content.js';
import type {
AstroAdapter,
AstroIntegration,
Expand All @@ -20,7 +21,6 @@ import type {
} from '../types/public/integrations.js';
import type { RouteData } from '../types/public/internal.js';
import { validateSupportedFeatures } from './features-validation.js';
import type { ContentEntryType, DataEntryType } from '../types/public/content.js';

async function withTakingALongTimeMsg<T>({
name,
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/runtime/server/hydration.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AstroError, AstroErrorData } from '../../core/errors/index.js';
import type {
SSRResult,
SSRLoadedRenderer,
AstroComponentMetadata,
SSRElement,
SSRLoadedRenderer,
SSRResult,
} from '../../types/public/internal.js';
import { escapeHTML } from './escape.js';
import { serializeProps } from './serialize.js';
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/render/astro/instance.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import type { ComponentSlots } from '../slot.js';
import type { AstroComponentFactory } from './factory.js';

import type { SSRResult } from '../../../../types/public/internal.js';
import { isPromise } from '../../util.js';
import { renderChild } from '../any.js';
import type { RenderDestination } from '../common.js';
import { isAPropagatingComponent } from './factory.js';
import { isHeadAndContent } from './head-and-content.js';
import type { SSRResult } from '../../../../types/public/internal.js';

type ComponentProps = Record<string | number, any>;

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/render/common.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { RenderInstruction } from './instruction.js';

import type { SSRResult } from '../../../types/public/internal.js';
import type { HTMLBytes, HTMLString } from '../escape.js';
import { markHTMLString } from '../escape.js';
import {
Expand All @@ -11,7 +12,6 @@ import {
import { renderAllHeadContent } from './head.js';
import { isRenderInstruction } from './instruction.js';
import { type SlotString, isSlotString } from './slot.js';
import type { SSRResult } from '../../../types/public/internal.js';

/**
* Possible chunk types to be written to the destination, and it'll
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/render/slot.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { renderTemplate } from './astro/render-template.js';
import type { RenderInstruction } from './instruction.js';

import type { SSRResult } from '../../../types/public/internal.js';
import { HTMLString, markHTMLString, unescapeHTML } from '../escape.js';
import { renderChild } from './any.js';
import { type RenderDestination, type RenderInstance, chunkToString } from './common.js';
import type { SSRResult } from '../../../types/public/internal.js';

type RenderTemplateResult = ReturnType<typeof renderTemplate>;
export type ComponentSlots = Record<string, ComponentSlotValue>;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/render/util.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { RenderDestination, RenderDestinationChunk, RenderFunction } from './common.js';

import { clsx } from 'clsx';
import { HTMLString, markHTMLString } from '../escape.js';
import type { SSRElement } from '../../../types/public/internal.js';
import { HTMLString, markHTMLString } from '../escape.js';

export const voidElementNames =
/^(area|base|br|col|command|embed|hr|img|input|keygen|link|meta|param|source|track|wbr)$/i;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/transition.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import cssesc from 'cssesc';
import { fade, slide } from '../../transitions/index.js';
import type { SSRResult } from '../../types/public/internal.js';
import type {
TransitionAnimation,
TransitionAnimationPair,
TransitionAnimationValue,
TransitionDirectionalAnimations,
} from '../../types/public/view-transitions.js';
import { markHTMLString } from './escape.js';
import type { SSRResult } from '../../types/public/internal.js';

const transitionNameMap = new WeakMap<SSRResult, number>();
function incrementTransitionNumber(result: SSRResult) {
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/types/public/content.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type { MarkdownHeading } from '@astrojs/markdown-remark';
import type { AstroComponentFactory } from '../../runtime/server/index.js';
import type * as rollup from 'rollup';
import type { DataEntry, RenderedContent } from '../../content/data-store.js';
import type { AstroComponentFactory } from '../../runtime/server/index.js';
import type { AstroConfig } from './config.js';
import type * as rollup from 'rollup';

export interface AstroInstance {
file: string;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/types/public/internal.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// TODO: Should the types here really be public?

import type { ErrorPayload as ViteErrorPayload } from 'vite';
import type { AstroCookies } from '../../core/cookies/cookies.js';
import type { AstroComponentInstance } from '../../runtime/server/index.js';
import type { Params } from './common.js';
import type { AstroConfig, RedirectConfig } from './config.js';
import type { AstroGlobal, AstroGlobalPartial } from './context.js';
import type { AstroRenderer } from './integrations.js';
import type { ErrorPayload as ViteErrorPayload } from 'vite';

export type { SSRManifest } from '../../core/app/types.js';

Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/vite-plugin-head/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import type { PluginMetadata } from '../vite-plugin-astro/types.js';

import { getParentModuleInfos, getTopLevelPageModuleInfos } from '../core/build/graph.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { SSRComponentMetadata, SSRResult } from '../types/public/internal.js';
import { getAstroMetadata } from '../vite-plugin-astro/index.js';
import type { SSRResult, SSRComponentMetadata } from '../types/public/internal.js';

// Detect this in comments, both in .astro components and in js/ts files.
const injectExp = /(?:^\/\/|\/\/!)\s*astro-head-inject/;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/types.d.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import './astro-jsx';
import type { AstroBuiltinAttributes } from './dist/types/public/elements.js';
import type { OmitIndexSignature, Simplify } from './dist/type-utils.js';
import type { AstroBuiltinAttributes } from './dist/types/public/elements.js';

/** Any supported HTML or SVG element name, as defined by the HTML specification */
export type HTMLTag = keyof astroHTML.JSX.DefinedIntrinsicElements;
Expand Down

0 comments on commit 9279d56

Please sign in to comment.