Skip to content

Commit

Permalink
[ci] format
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico authored and astrobot-houston committed Mar 4, 2025
1 parent 0025df3 commit f61d442
Show file tree
Hide file tree
Showing 12 changed files with 35 additions and 35 deletions.
16 changes: 7 additions & 9 deletions packages/astro/src/actions/loadActions.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import type {ModuleLoader} from "../core/module-loader/index.js";
import {ASTRO_ACTIONS_INTERNAL_MODULE_ID} from "./consts.js";
import type {SSRActions} from "../core/app/types.js";
import {ActionsCantBeLoaded} from "../core/errors/errors-data.js";
import {AstroError} from "../core/errors/index.js";
import type { SSRActions } from '../core/app/types.js';
import { ActionsCantBeLoaded } from '../core/errors/errors-data.js';
import { AstroError } from '../core/errors/index.js';
import type { ModuleLoader } from '../core/module-loader/index.js';
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from './consts.js';

/**
* It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.
Expand All @@ -11,10 +11,8 @@ import {AstroError} from "../core/errors/index.js";
*/
export async function loadActions(moduleLoader: ModuleLoader) {
try {
return (await moduleLoader.import(
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
)) as SSRActions;
return (await moduleLoader.import(ASTRO_ACTIONS_INTERNAL_MODULE_ID)) as SSRActions;
} catch (error: any) {
throw new AstroError(ActionsCantBeLoaded, {cause: error});
throw new AstroError(ActionsCantBeLoaded, { cause: error });
}
}
10 changes: 5 additions & 5 deletions packages/astro/src/actions/plugins.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
import type fsMod from 'node:fs';
import type { Plugin as VitePlugin } from 'vite';
import { addRollupInput } from '../core/build/add-rollup-input.js';
import type { BuildInternals } from '../core/build/internal.js';
import type { StaticBuildOptions } from '../core/build/types.js';
import { shouldAppendForwardSlash } from '../core/build/util.js';
import { getOutputDirectory } from '../prerender/utils.js';
import type { AstroSettings } from '../types/astro.js';
import {
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
NOOP_ACTIONS,
RESOLVED_ASTRO_ACTIONS_INTERNAL_MODULE_ID,
RESOLVED_VIRTUAL_MODULE_ID,
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
VIRTUAL_MODULE_ID,
} from './consts.js';
import { isActionsFilePresent } from './utils.js';
import { getOutputDirectory } from '../prerender/utils.js';
import type { StaticBuildOptions } from '../core/build/types.js';
import type { BuildInternals } from '../core/build/internal.js';
import { addRollupInput } from '../core/build/add-rollup-input.js';

/**
* This plugin is responsible to load the known file `actions/index.js` / `actions.js`
Expand Down
5 changes: 4 additions & 1 deletion packages/astro/src/actions/runtime/virtual/shared.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { parse as devalueParse, stringify as devalueStringify } from 'devalue';
import type { z } from 'zod';
import { REDIRECT_STATUS_CODES } from '../../../core/constants.js';
import {ActionCalledFromServerError, ActionsReturnedInvalidDataError} from '../../../core/errors/errors-data.js';
import {
ActionCalledFromServerError,
ActionsReturnedInvalidDataError,
} from '../../../core/errors/errors-data.js';
import { AstroError } from '../../../core/errors/errors.js';
import { appendForwardSlash as _appendForwardSlash } from '../../../core/path.js';
import { ACTION_QUERY_PARAMS as _ACTION_QUERY_PARAMS } from '../../consts.js';
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/app/types.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ZodType } from 'zod';
import type { ActionAccept, ActionClient } from '../../actions/runtime/virtual/server.js';
import type { RoutingStrategies } from '../../i18n/utils.js';
import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
import type { AstroMiddlewareInstance } from '../../types/public/common.js';
Expand All @@ -9,8 +11,6 @@ import type {
SSRResult,
} from '../../types/public/internal.js';
import type { SinglePageBuiltModule } from '../build/types.js';
import type { ActionAccept, ActionClient } from '../../actions/runtime/virtual/server.js';
import type { ZodType } from 'zod';

export type ComponentPath = string;

Expand Down
12 changes: 6 additions & 6 deletions packages/astro/src/core/base-pipeline.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import type { ZodType } from 'zod';
import type { ActionAccept, ActionClient } from '../actions/runtime/virtual/server.js';
import { createI18nMiddleware } from '../i18n/middleware.js';
import type { ComponentInstance } from '../types/astro.js';
import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
Expand All @@ -9,16 +11,14 @@ import type {
SSRResult,
} from '../types/public/internal.js';
import { createOriginCheckMiddleware } from './app/middlewares.js';
import type { SSRActions } from './app/types.js';
import { ActionNotFoundError } from './errors/errors-data.js';
import { AstroError } from './errors/index.js';
import type { Logger } from './logger/core.js';
import { NOOP_MIDDLEWARE_FN } from './middleware/noop-middleware.js';
import { sequence } from './middleware/sequence.js';
import { RouteCache } from './render/route-cache.js';
import { createDefaultRoutes } from './routing/default.js';
import type { SSRActions } from './app/types.js';
import type { ActionAccept, ActionClient } from '../actions/runtime/virtual/server.js';
import type { ZodType } from 'zod';
import { AstroError } from './errors/index.js';
import { ActionNotFoundError } from './errors/errors-data.js';

/**
* The `Pipeline` represents the static parts of rendering that do not change between requests.
Expand Down Expand Up @@ -122,7 +122,7 @@ export abstract class Pipeline {
return this.resolvedMiddleware;
}
}

setActions(actions: SSRActions) {
this.resolvedActions = actions;
}
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
import { astroHeadBuildPlugin } from '../../../vite-plugin-head/index.js';
import type { AstroBuildPluginContainer } from '../plugin.js';
import { pluginActions } from './plugin-actions.js';
import { pluginAnalyzer } from './plugin-analyzer.js';
import { pluginChunks } from './plugin-chunks.js';
import { pluginComponentEntry } from './plugin-component-entry.js';
Expand All @@ -13,7 +14,6 @@ import { pluginPrerender } from './plugin-prerender.js';
import { pluginRenderers } from './plugin-renderers.js';
import { pluginScripts } from './plugin-scripts.js';
import { pluginSSR } from './plugin-ssr.js';
import { pluginActions } from './plugin-actions.js';

export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
register(pluginComponentEntry(internals));
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/core/build/plugins/plugin-actions.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { vitePluginActionsBuild } from '../../../actions/plugins.js';
import type { StaticBuildOptions } from '../types.js';
import type { BuildInternals } from '../internal.js';
import type { AstroBuildPlugin } from '../plugin.js';
import type { StaticBuildOptions } from '../types.js';

export function pluginActions(
opts: StaticBuildOptions,
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/core/build/plugins/plugin-ssr.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import type { Plugin as VitePlugin } from 'vite';
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from '../../../actions/consts.js';
import type { AstroAdapter } from '../../../types/public/integrations.js';
import { MIDDLEWARE_MODULE_ID } from '../../middleware/vite-plugin.js';
import { routeIsRedirect } from '../../redirects/index.js';
import { VIRTUAL_ISLAND_MAP_ID } from '../../server-islands/vite-plugin-server-islands.js';
import { addRollupInput } from '../add-rollup-input.js';
Expand All @@ -10,8 +12,6 @@ import { SSR_MANIFEST_VIRTUAL_MODULE_ID } from './plugin-manifest.js';
import { ASTRO_PAGE_MODULE_ID } from './plugin-pages.js';
import { RENDERERS_MODULE_ID } from './plugin-renderers.js';
import { getVirtualModulePageName } from './util.js';
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from '../../../actions/consts.js';
import { MIDDLEWARE_MODULE_ID } from '../../middleware/vite-plugin.js';

export const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry';
export const RESOLVED_SSR_VIRTUAL_MODULE_ID = '\0' + SSR_VIRTUAL_MODULE_ID;
Expand Down
1 change: 0 additions & 1 deletion packages/astro/src/core/errors/errors-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -901,7 +901,6 @@ export const MiddlewareCantBeLoaded = {
message: 'An unknown error was thrown while loading your middleware.',
} satisfies ErrorData;


/**
* @docs
* @description
Expand Down
8 changes: 4 additions & 4 deletions packages/astro/src/core/render-context.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { ActionAPIContext } from '../actions/runtime/utils.js';
import { getActionContext } from '../actions/runtime/virtual/server.js';
import { deserializeActionResult } from '../actions/runtime/virtual/shared.js';
import { createCallAction, createGetActionResult, hasActionPayload } from '../actions/utils.js';
import {
Expand All @@ -12,6 +13,7 @@ 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 type { SSRActions } from './app/types.js';
import {
ASTRO_VERSION,
REROUTE_DIRECTIVE_HEADER,
Expand All @@ -32,8 +34,6 @@ import { type Pipeline, Slots, getParams, getProps } from './render/index.js';
import { isRoute404or500, isRouteExternalRedirect, isRouteServerIsland } from './routing/match.js';
import { copyRequest, getOriginPathname, setOriginPathname } from './routing/rewrite.js';
import { AstroSession } from './session.js';
import { getActionContext } from '../actions/runtime/virtual/server.js';
import type {SSRActions} from "./app/types.js";

export const apiContextRoutesSymbol = Symbol.for('context.routes');

Expand Down Expand Up @@ -83,13 +83,13 @@ export class RenderContext {
status = 200,
props,
partial = undefined,
actions
actions,
}: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData' | 'clientAddress'> &
Partial<
Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props' | 'partial' | 'actions'>
>): Promise<RenderContext> {
const pipelineMiddleware = await pipeline.getMiddleware();
const pipelineActions = actions ?? await pipeline.getActions();
const pipelineActions = actions ?? (await pipeline.getActions());
setOriginPathname(request, pathname);
return new RenderContext(
pipeline,
Expand Down
4 changes: 2 additions & 2 deletions packages/astro/src/vite-plugin-astro-server/route.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type http from 'node:http';
import { loadActions } from '../actions/loadActions.js';
import {
DEFAULT_404_COMPONENT,
NOOP_MIDDLEWARE_HEADER,
Expand All @@ -22,7 +23,6 @@ import type { ComponentInstance, RoutesList } from '../types/astro.js';
import type { RouteData } from '../types/public/internal.js';
import type { DevPipeline } from './pipeline.js';
import { writeSSRResult, writeWebResponse } from './response.js';
import {loadActions} from "../actions/loadActions.js";

type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
...args: any
Expand Down Expand Up @@ -195,7 +195,7 @@ export async function handleRoute({
request,
routeData: route,
clientAddress: incomingRequest.socket.remoteAddress,
actions
actions,
});

let response;
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/templates/actions.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ import {
ACTION_QUERY_PARAMS,
ActionError,
appendForwardSlash,
astroCalledServerError,
deserializeActionResult,
getActionQueryString,
astroCalledServerError,
} from 'astro:actions';

const apiContextRoutesSymbol = Symbol.for('context.routes');
Expand Down

0 comments on commit f61d442

Please sign in to comment.