From 9279d56c9f152c88e174169818e6297d2f0126cf Mon Sep 17 00:00:00 2001 From: Princesseuh <3019731+Princesseuh@users.noreply.github.com> Date: Thu, 15 Aug 2024 05:28:17 +0200 Subject: [PATCH] chore: organize imports --- packages/astro/src/container/index.ts | 2 +- packages/astro/src/content/loaders/glob.ts | 2 +- packages/astro/src/content/types-generator.ts | 2 +- packages/astro/src/content/utils.ts | 2 +- .../astro/src/content/vite-plugin-content-assets.ts | 2 +- .../astro/src/content/vite-plugin-content-imports.ts | 12 ++++++------ packages/astro/src/core/build/generate.ts | 2 +- packages/astro/src/core/errors/dev/utils.ts | 2 +- packages/astro/src/core/errors/dev/vite.ts | 2 +- packages/astro/src/i18n/index.ts | 2 +- packages/astro/src/integrations/hooks.ts | 2 +- packages/astro/src/runtime/server/hydration.ts | 4 ++-- .../src/runtime/server/render/astro/instance.ts | 2 +- packages/astro/src/runtime/server/render/common.ts | 2 +- packages/astro/src/runtime/server/render/slot.ts | 2 +- packages/astro/src/runtime/server/render/util.ts | 2 +- packages/astro/src/runtime/server/transition.ts | 2 +- packages/astro/src/types/public/content.ts | 4 ++-- packages/astro/src/types/public/internal.ts | 2 +- packages/astro/src/vite-plugin-head/index.ts | 2 +- packages/astro/types.d.ts | 2 +- 21 files changed, 28 insertions(+), 28 deletions(-) diff --git a/packages/astro/src/container/index.ts b/packages/astro/src/container/index.ts index 6613a18099bf..056c785b9526 100644 --- a/packages/astro/src/container/index.ts +++ b/packages/astro/src/container/index.ts @@ -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, @@ -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 diff --git a/packages/astro/src/content/loaders/glob.ts b/packages/astro/src/content/loaders/glob.ts index 7c903fc130f7..27af34196ad0 100644 --- a/packages/astro/src/content/loaders/glob.ts +++ b/packages/astro/src/content/loaders/glob.ts @@ -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. */ diff --git a/packages/astro/src/content/types-generator.ts b/packages/astro/src/content/types-generator.ts index 15d7d032d33f..52ed9a72fdf8 100644 --- a/packages/astro/src/content/types-generator.ts +++ b/packages/astro/src/content/types-generator.ts @@ -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, @@ -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 }; diff --git a/packages/astro/src/content/utils.ts b/packages/astro/src/content/utils.ts index b16030f26b4d..31c679fa73d7 100644 --- a/packages/astro/src/content/utils.ts +++ b/packages/astro/src/content/utils.ts @@ -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, @@ -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()`. diff --git a/packages/astro/src/content/vite-plugin-content-assets.ts b/packages/astro/src/content/vite-plugin-content-assets.ts index 8382142e29ff..059cd92fa6af 100644 --- a/packages/astro/src/content/vite-plugin-content-assets.ts +++ b/packages/astro/src/content/vite-plugin-content-assets.ts @@ -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 { @@ -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, diff --git a/packages/astro/src/content/vite-plugin-content-imports.ts b/packages/astro/src/content/vite-plugin-content-imports.ts index 5c545f3f34b8..62f129052a8d 100644 --- a/packages/astro/src/content/vite-plugin-content-imports.ts +++ b/packages/astro/src/content/vite-plugin-content-imports.ts @@ -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, @@ -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, diff --git a/packages/astro/src/core/build/generate.ts b/packages/astro/src/core/build/generate.ts index 8cc5d97bd435..1f71f2d8a55d 100644 --- a/packages/astro/src/core/build/generate.ts +++ b/packages/astro/src/core/build/generate.ts @@ -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'; diff --git a/packages/astro/src/core/errors/dev/utils.ts b/packages/astro/src/core/errors/dev/utils.ts index 58a061b477e6..c082a81937de 100644 --- a/packages/astro/src/core/errors/dev/utils.ts +++ b/packages/astro/src/core/errors/dev/utils.ts @@ -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]; diff --git a/packages/astro/src/core/errors/dev/vite.ts b/packages/astro/src/core/errors/dev/vite.ts index b45a02641e5a..c944ad78d686 100644 --- a/packages/astro/src/core/errors/dev/vite.ts +++ b/packages/astro/src/core/errors/dev/vite.ts @@ -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, diff --git a/packages/astro/src/i18n/index.ts b/packages/astro/src/i18n/index.ts index b8fb53543e78..c7e676f75803 100644 --- a/packages/astro/src/i18n/index.ts +++ b/packages/astro/src/i18n/index.ts @@ -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'; @@ -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 { diff --git a/packages/astro/src/integrations/hooks.ts b/packages/astro/src/integrations/hooks.ts index a9ac630c15e1..39d8ab69feb0 100644 --- a/packages/astro/src/integrations/hooks.ts +++ b/packages/astro/src/integrations/hooks.ts @@ -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, @@ -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({ name, diff --git a/packages/astro/src/runtime/server/hydration.ts b/packages/astro/src/runtime/server/hydration.ts index dab7ac343bde..982ff9977ecb 100644 --- a/packages/astro/src/runtime/server/hydration.ts +++ b/packages/astro/src/runtime/server/hydration.ts @@ -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'; diff --git a/packages/astro/src/runtime/server/render/astro/instance.ts b/packages/astro/src/runtime/server/render/astro/instance.ts index 16dc2bf04324..029231a28d6d 100644 --- a/packages/astro/src/runtime/server/render/astro/instance.ts +++ b/packages/astro/src/runtime/server/render/astro/instance.ts @@ -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; diff --git a/packages/astro/src/runtime/server/render/common.ts b/packages/astro/src/runtime/server/render/common.ts index c681112204e7..77f05dfccec6 100644 --- a/packages/astro/src/runtime/server/render/common.ts +++ b/packages/astro/src/runtime/server/render/common.ts @@ -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 { @@ -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 diff --git a/packages/astro/src/runtime/server/render/slot.ts b/packages/astro/src/runtime/server/render/slot.ts index 7d47e63ec510..0df37440622c 100644 --- a/packages/astro/src/runtime/server/render/slot.ts +++ b/packages/astro/src/runtime/server/render/slot.ts @@ -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; export type ComponentSlots = Record; diff --git a/packages/astro/src/runtime/server/render/util.ts b/packages/astro/src/runtime/server/render/util.ts index 07766449e44b..19ac2f2b1928 100644 --- a/packages/astro/src/runtime/server/render/util.ts +++ b/packages/astro/src/runtime/server/render/util.ts @@ -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; diff --git a/packages/astro/src/runtime/server/transition.ts b/packages/astro/src/runtime/server/transition.ts index 4777a287ad5e..4baae442afb6 100644 --- a/packages/astro/src/runtime/server/transition.ts +++ b/packages/astro/src/runtime/server/transition.ts @@ -1,5 +1,6 @@ import cssesc from 'cssesc'; import { fade, slide } from '../../transitions/index.js'; +import type { SSRResult } from '../../types/public/internal.js'; import type { TransitionAnimation, TransitionAnimationPair, @@ -7,7 +8,6 @@ import type { TransitionDirectionalAnimations, } from '../../types/public/view-transitions.js'; import { markHTMLString } from './escape.js'; -import type { SSRResult } from '../../types/public/internal.js'; const transitionNameMap = new WeakMap(); function incrementTransitionNumber(result: SSRResult) { diff --git a/packages/astro/src/types/public/content.ts b/packages/astro/src/types/public/content.ts index e4484887e335..ac58c918f48f 100644 --- a/packages/astro/src/types/public/content.ts +++ b/packages/astro/src/types/public/content.ts @@ -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; diff --git a/packages/astro/src/types/public/internal.ts b/packages/astro/src/types/public/internal.ts index 22156546fdb8..bee15c6f75c0 100644 --- a/packages/astro/src/types/public/internal.ts +++ b/packages/astro/src/types/public/internal.ts @@ -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'; diff --git a/packages/astro/src/vite-plugin-head/index.ts b/packages/astro/src/vite-plugin-head/index.ts index 14ab668607a3..c9ec2460dcb6 100644 --- a/packages/astro/src/vite-plugin-head/index.ts +++ b/packages/astro/src/vite-plugin-head/index.ts @@ -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/; diff --git a/packages/astro/types.d.ts b/packages/astro/types.d.ts index f3619afb8d43..cc0f1c3d2371 100644 --- a/packages/astro/types.d.ts +++ b/packages/astro/types.d.ts @@ -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;