Skip to content

Commit f61d442

Browse files
ematipicoastrobot-houston
authored andcommitted
[ci] format
1 parent 0025df3 commit f61d442

File tree

12 files changed

+35
-35
lines changed

12 files changed

+35
-35
lines changed
+7-9
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
import type {ModuleLoader} from "../core/module-loader/index.js";
2-
import {ASTRO_ACTIONS_INTERNAL_MODULE_ID} from "./consts.js";
3-
import type {SSRActions} from "../core/app/types.js";
4-
import {ActionsCantBeLoaded} from "../core/errors/errors-data.js";
5-
import {AstroError} from "../core/errors/index.js";
1+
import type { SSRActions } from '../core/app/types.js';
2+
import { ActionsCantBeLoaded } from '../core/errors/errors-data.js';
3+
import { AstroError } from '../core/errors/index.js';
4+
import type { ModuleLoader } from '../core/module-loader/index.js';
5+
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from './consts.js';
66

77
/**
88
* It accepts a module loader and the astro settings, and it attempts to load the middlewares defined in the configuration.
@@ -11,10 +11,8 @@ import {AstroError} from "../core/errors/index.js";
1111
*/
1212
export async function loadActions(moduleLoader: ModuleLoader) {
1313
try {
14-
return (await moduleLoader.import(
15-
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
16-
)) as SSRActions;
14+
return (await moduleLoader.import(ASTRO_ACTIONS_INTERNAL_MODULE_ID)) as SSRActions;
1715
} catch (error: any) {
18-
throw new AstroError(ActionsCantBeLoaded, {cause: error});
16+
throw new AstroError(ActionsCantBeLoaded, { cause: error });
1917
}
2018
}

packages/astro/src/actions/plugins.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
import type fsMod from 'node:fs';
22
import type { Plugin as VitePlugin } from 'vite';
3+
import { addRollupInput } from '../core/build/add-rollup-input.js';
4+
import type { BuildInternals } from '../core/build/internal.js';
5+
import type { StaticBuildOptions } from '../core/build/types.js';
36
import { shouldAppendForwardSlash } from '../core/build/util.js';
7+
import { getOutputDirectory } from '../prerender/utils.js';
48
import type { AstroSettings } from '../types/astro.js';
59
import {
10+
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
611
NOOP_ACTIONS,
712
RESOLVED_ASTRO_ACTIONS_INTERNAL_MODULE_ID,
813
RESOLVED_VIRTUAL_MODULE_ID,
9-
ASTRO_ACTIONS_INTERNAL_MODULE_ID,
1014
VIRTUAL_MODULE_ID,
1115
} from './consts.js';
1216
import { isActionsFilePresent } from './utils.js';
13-
import { getOutputDirectory } from '../prerender/utils.js';
14-
import type { StaticBuildOptions } from '../core/build/types.js';
15-
import type { BuildInternals } from '../core/build/internal.js';
16-
import { addRollupInput } from '../core/build/add-rollup-input.js';
1717

1818
/**
1919
* This plugin is responsible to load the known file `actions/index.js` / `actions.js`

packages/astro/src/actions/runtime/virtual/shared.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { parse as devalueParse, stringify as devalueStringify } from 'devalue';
22
import type { z } from 'zod';
33
import { REDIRECT_STATUS_CODES } from '../../../core/constants.js';
4-
import {ActionCalledFromServerError, ActionsReturnedInvalidDataError} from '../../../core/errors/errors-data.js';
4+
import {
5+
ActionCalledFromServerError,
6+
ActionsReturnedInvalidDataError,
7+
} from '../../../core/errors/errors-data.js';
58
import { AstroError } from '../../../core/errors/errors.js';
69
import { appendForwardSlash as _appendForwardSlash } from '../../../core/path.js';
710
import { ACTION_QUERY_PARAMS as _ACTION_QUERY_PARAMS } from '../../consts.js';

packages/astro/src/core/app/types.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ZodType } from 'zod';
2+
import type { ActionAccept, ActionClient } from '../../actions/runtime/virtual/server.js';
13
import type { RoutingStrategies } from '../../i18n/utils.js';
24
import type { ComponentInstance, SerializedRouteData } from '../../types/astro.js';
35
import type { AstroMiddlewareInstance } from '../../types/public/common.js';
@@ -9,8 +11,6 @@ import type {
911
SSRResult,
1012
} from '../../types/public/internal.js';
1113
import type { SinglePageBuiltModule } from '../build/types.js';
12-
import type { ActionAccept, ActionClient } from '../../actions/runtime/virtual/server.js';
13-
import type { ZodType } from 'zod';
1414

1515
export type ComponentPath = string;
1616

packages/astro/src/core/base-pipeline.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import type { ZodType } from 'zod';
2+
import type { ActionAccept, ActionClient } from '../actions/runtime/virtual/server.js';
13
import { createI18nMiddleware } from '../i18n/middleware.js';
24
import type { ComponentInstance } from '../types/astro.js';
35
import type { MiddlewareHandler, RewritePayload } from '../types/public/common.js';
@@ -9,16 +11,14 @@ import type {
911
SSRResult,
1012
} from '../types/public/internal.js';
1113
import { createOriginCheckMiddleware } from './app/middlewares.js';
14+
import type { SSRActions } from './app/types.js';
15+
import { ActionNotFoundError } from './errors/errors-data.js';
16+
import { AstroError } from './errors/index.js';
1217
import type { Logger } from './logger/core.js';
1318
import { NOOP_MIDDLEWARE_FN } from './middleware/noop-middleware.js';
1419
import { sequence } from './middleware/sequence.js';
1520
import { RouteCache } from './render/route-cache.js';
1621
import { createDefaultRoutes } from './routing/default.js';
17-
import type { SSRActions } from './app/types.js';
18-
import type { ActionAccept, ActionClient } from '../actions/runtime/virtual/server.js';
19-
import type { ZodType } from 'zod';
20-
import { AstroError } from './errors/index.js';
21-
import { ActionNotFoundError } from './errors/errors-data.js';
2222

2323
/**
2424
* The `Pipeline` represents the static parts of rendering that do not change between requests.
@@ -122,7 +122,7 @@ export abstract class Pipeline {
122122
return this.resolvedMiddleware;
123123
}
124124
}
125-
125+
126126
setActions(actions: SSRActions) {
127127
this.resolvedActions = actions;
128128
}

packages/astro/src/core/build/plugins/index.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { astroConfigBuildPlugin } from '../../../content/vite-plugin-content-assets.js';
22
import { astroHeadBuildPlugin } from '../../../vite-plugin-head/index.js';
33
import type { AstroBuildPluginContainer } from '../plugin.js';
4+
import { pluginActions } from './plugin-actions.js';
45
import { pluginAnalyzer } from './plugin-analyzer.js';
56
import { pluginChunks } from './plugin-chunks.js';
67
import { pluginComponentEntry } from './plugin-component-entry.js';
@@ -13,7 +14,6 @@ import { pluginPrerender } from './plugin-prerender.js';
1314
import { pluginRenderers } from './plugin-renderers.js';
1415
import { pluginScripts } from './plugin-scripts.js';
1516
import { pluginSSR } from './plugin-ssr.js';
16-
import { pluginActions } from './plugin-actions.js';
1717

1818
export function registerAllPlugins({ internals, options, register }: AstroBuildPluginContainer) {
1919
register(pluginComponentEntry(internals));

packages/astro/src/core/build/plugins/plugin-actions.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { vitePluginActionsBuild } from '../../../actions/plugins.js';
2-
import type { StaticBuildOptions } from '../types.js';
32
import type { BuildInternals } from '../internal.js';
43
import type { AstroBuildPlugin } from '../plugin.js';
4+
import type { StaticBuildOptions } from '../types.js';
55

66
export function pluginActions(
77
opts: StaticBuildOptions,

packages/astro/src/core/build/plugins/plugin-ssr.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
import type { Plugin as VitePlugin } from 'vite';
2+
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from '../../../actions/consts.js';
23
import type { AstroAdapter } from '../../../types/public/integrations.js';
4+
import { MIDDLEWARE_MODULE_ID } from '../../middleware/vite-plugin.js';
35
import { routeIsRedirect } from '../../redirects/index.js';
46
import { VIRTUAL_ISLAND_MAP_ID } from '../../server-islands/vite-plugin-server-islands.js';
57
import { addRollupInput } from '../add-rollup-input.js';
@@ -10,8 +12,6 @@ import { SSR_MANIFEST_VIRTUAL_MODULE_ID } from './plugin-manifest.js';
1012
import { ASTRO_PAGE_MODULE_ID } from './plugin-pages.js';
1113
import { RENDERERS_MODULE_ID } from './plugin-renderers.js';
1214
import { getVirtualModulePageName } from './util.js';
13-
import { ASTRO_ACTIONS_INTERNAL_MODULE_ID } from '../../../actions/consts.js';
14-
import { MIDDLEWARE_MODULE_ID } from '../../middleware/vite-plugin.js';
1515

1616
export const SSR_VIRTUAL_MODULE_ID = '@astrojs-ssr-virtual-entry';
1717
export const RESOLVED_SSR_VIRTUAL_MODULE_ID = '\0' + SSR_VIRTUAL_MODULE_ID;

packages/astro/src/core/errors/errors-data.ts

-1
Original file line numberDiff line numberDiff line change
@@ -901,7 +901,6 @@ export const MiddlewareCantBeLoaded = {
901901
message: 'An unknown error was thrown while loading your middleware.',
902902
} satisfies ErrorData;
903903

904-
905904
/**
906905
* @docs
907906
* @description

packages/astro/src/core/render-context.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type { ActionAPIContext } from '../actions/runtime/utils.js';
2+
import { getActionContext } from '../actions/runtime/virtual/server.js';
23
import { deserializeActionResult } from '../actions/runtime/virtual/shared.js';
34
import { createCallAction, createGetActionResult, hasActionPayload } from '../actions/utils.js';
45
import {
@@ -12,6 +13,7 @@ import type { ComponentInstance } from '../types/astro.js';
1213
import type { MiddlewareHandler, Props, RewritePayload } from '../types/public/common.js';
1314
import type { APIContext, AstroGlobal, AstroGlobalPartial } from '../types/public/context.js';
1415
import type { RouteData, SSRResult } from '../types/public/internal.js';
16+
import type { SSRActions } from './app/types.js';
1517
import {
1618
ASTRO_VERSION,
1719
REROUTE_DIRECTIVE_HEADER,
@@ -32,8 +34,6 @@ import { type Pipeline, Slots, getParams, getProps } from './render/index.js';
3234
import { isRoute404or500, isRouteExternalRedirect, isRouteServerIsland } from './routing/match.js';
3335
import { copyRequest, getOriginPathname, setOriginPathname } from './routing/rewrite.js';
3436
import { AstroSession } from './session.js';
35-
import { getActionContext } from '../actions/runtime/virtual/server.js';
36-
import type {SSRActions} from "./app/types.js";
3737

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

@@ -83,13 +83,13 @@ export class RenderContext {
8383
status = 200,
8484
props,
8585
partial = undefined,
86-
actions
86+
actions,
8787
}: Pick<RenderContext, 'pathname' | 'pipeline' | 'request' | 'routeData' | 'clientAddress'> &
8888
Partial<
8989
Pick<RenderContext, 'locals' | 'middleware' | 'status' | 'props' | 'partial' | 'actions'>
9090
>): Promise<RenderContext> {
9191
const pipelineMiddleware = await pipeline.getMiddleware();
92-
const pipelineActions = actions ?? await pipeline.getActions();
92+
const pipelineActions = actions ?? (await pipeline.getActions());
9393
setOriginPathname(request, pathname);
9494
return new RenderContext(
9595
pipeline,

packages/astro/src/vite-plugin-astro-server/route.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import type http from 'node:http';
2+
import { loadActions } from '../actions/loadActions.js';
23
import {
34
DEFAULT_404_COMPONENT,
45
NOOP_MIDDLEWARE_HEADER,
@@ -22,7 +23,6 @@ import type { ComponentInstance, RoutesList } from '../types/astro.js';
2223
import type { RouteData } from '../types/public/internal.js';
2324
import type { DevPipeline } from './pipeline.js';
2425
import { writeSSRResult, writeWebResponse } from './response.js';
25-
import {loadActions} from "../actions/loadActions.js";
2626

2727
type AsyncReturnType<T extends (...args: any) => Promise<any>> = T extends (
2828
...args: any
@@ -195,7 +195,7 @@ export async function handleRoute({
195195
request,
196196
routeData: route,
197197
clientAddress: incomingRequest.socket.remoteAddress,
198-
actions
198+
actions,
199199
});
200200

201201
let response;

packages/astro/templates/actions.mjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@ import {
22
ACTION_QUERY_PARAMS,
33
ActionError,
44
appendForwardSlash,
5+
astroCalledServerError,
56
deserializeActionResult,
67
getActionQueryString,
7-
astroCalledServerError,
88
} from 'astro:actions';
99

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

0 commit comments

Comments
 (0)