| class BuildTimeAstroVersionProvider { | ||
| // Injected during the build through esbuild define | ||
| version = "6.0.2"; | ||
| version = "6.0.3"; | ||
| } | ||
@@ -5,0 +5,0 @@ export { |
@@ -192,3 +192,3 @@ import { existsSync, promises as fs } from "node:fs"; | ||
| } | ||
| if (previousAstroVersion && previousAstroVersion !== "6.0.2") { | ||
| if (previousAstroVersion && previousAstroVersion !== "6.0.3") { | ||
| logger.info("Astro version changed"); | ||
@@ -201,4 +201,4 @@ shouldClear = true; | ||
| } | ||
| if ("6.0.2") { | ||
| this.#store.metaStore().set("astro-version", "6.0.2"); | ||
| if ("6.0.3") { | ||
| this.#store.metaStore().set("astro-version", "6.0.3"); | ||
| } | ||
@@ -205,0 +205,0 @@ if (currentConfigDigest) { |
@@ -142,2 +142,12 @@ import fs from "node:fs"; | ||
| } | ||
| for (const { route: generatedRoute } of filteredPaths) { | ||
| if (generatedRoute.distURL && generatedRoute.distURL.length > 0) { | ||
| for (const pageData of Object.values(options.allPages)) { | ||
| if (pageData.route.route === generatedRoute.route && pageData.route.component === generatedRoute.component) { | ||
| pageData.route.distURL = generatedRoute.distURL; | ||
| break; | ||
| } | ||
| } | ||
| } | ||
| } | ||
| const staticImageList = getStaticImageList(); | ||
@@ -144,0 +154,0 @@ if (prerenderer.collectStaticImages) { |
@@ -70,2 +70,6 @@ export declare const ASTRO_VERSION: string; | ||
| /** | ||
| * Use this symbol to opt into handling prerender routes in Astro core dev middleware. | ||
| */ | ||
| export declare const devPrerenderMiddlewareSymbol: unique symbol; | ||
| /** | ||
| * The symbol used as a field on the request object to store a cleanup callback associated with aborting the request when the underlying socket closes. | ||
@@ -72,0 +76,0 @@ */ |
@@ -1,2 +0,2 @@ | ||
| const ASTRO_VERSION = "6.0.2"; | ||
| const ASTRO_VERSION = "6.0.3"; | ||
| const ASTRO_GENERATOR = `Astro v${ASTRO_VERSION}`; | ||
@@ -15,2 +15,3 @@ const REROUTE_DIRECTIVE_HEADER = "X-Astro-Reroute"; | ||
| const pipelineSymbol = /* @__PURE__ */ Symbol.for("astro.pipeline"); | ||
| const devPrerenderMiddlewareSymbol = /* @__PURE__ */ Symbol.for("astro.devPrerenderMiddleware"); | ||
| const nodeRequestAbortControllerCleanupSymbol = /* @__PURE__ */ Symbol.for( | ||
@@ -61,2 +62,3 @@ "astro.nodeRequestAbortControllerCleanup" | ||
| clientLocalsSymbol, | ||
| devPrerenderMiddlewareSymbol, | ||
| nodeRequestAbortControllerCleanupSymbol, | ||
@@ -63,0 +65,0 @@ originPathnameSymbol, |
@@ -29,3 +29,3 @@ import fs from "node:fs"; | ||
| const logger = restart.container.logger; | ||
| const currentVersion = "6.0.2"; | ||
| const currentVersion = "6.0.3"; | ||
| const isPrerelease = currentVersion.includes("-"); | ||
@@ -32,0 +32,0 @@ if (!isPrerelease) { |
@@ -272,3 +272,3 @@ import colors from "piccolore"; | ||
| ` ${bgGreen(black(` ${commandName} `))} ${green( | ||
| `v${"6.0.2"}` | ||
| `v${"6.0.3"}` | ||
| )} ${headline}` | ||
@@ -275,0 +275,0 @@ ); |
@@ -62,6 +62,6 @@ import { | ||
| const data = JSON.parse(raw); | ||
| if ("slots" in data && typeof data.slots === "object") { | ||
| if (Object.hasOwn(data, "slots") && typeof data.slots === "object") { | ||
| return badRequest("Plaintext slots are not allowed. Slots must be encrypted."); | ||
| } | ||
| if ("componentExport" in data && typeof data.componentExport === "string") { | ||
| if (Object.hasOwn(data, "componentExport") && typeof data.componentExport === "string") { | ||
| return badRequest( | ||
@@ -68,0 +68,0 @@ "Plaintext componentExport is not allowed. componentExport must be encrypted." |
@@ -6,3 +6,3 @@ import { AsyncLocalStorage } from "node:async_hooks"; | ||
| import { toRoutingStrategy } from "../core/app/entrypoints/index.js"; | ||
| import { ASTRO_VITE_ENVIRONMENT_NAMES } from "../core/constants.js"; | ||
| import { ASTRO_VITE_ENVIRONMENT_NAMES, devPrerenderMiddlewareSymbol } from "../core/constants.js"; | ||
| import { | ||
@@ -23,2 +23,3 @@ getAlgorithm, | ||
| import { createViteLoader } from "../core/module-loader/index.js"; | ||
| import { matchAllRoutes } from "../core/routing/match.js"; | ||
| import { resolveMiddlewareMode } from "../integrations/adapter-utils.js"; | ||
@@ -45,11 +46,19 @@ import { SERIALIZED_MANIFEST_ID } from "../manifest/serialized.js"; | ||
| async configureServer(viteServer) { | ||
| if (!isRunnableDevEnvironment(viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr])) { | ||
| const ssrEnvironment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]; | ||
| const prerenderEnvironment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.prerender]; | ||
| const runnableSsrEnvironment = isRunnableDevEnvironment(ssrEnvironment) ? ssrEnvironment : void 0; | ||
| const runnablePrerenderEnvironment = isRunnableDevEnvironment(prerenderEnvironment) ? prerenderEnvironment : void 0; | ||
| if (!runnableSsrEnvironment && !runnablePrerenderEnvironment) { | ||
| return; | ||
| } | ||
| const environment = viteServer.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]; | ||
| const loader = createViteLoader(viteServer, environment); | ||
| const { default: createAstroServerApp } = await environment.runner.import(ASTRO_DEV_SERVER_APP_ID); | ||
| const controller = createController({ loader }); | ||
| const { handler } = await createAstroServerApp(controller, settings, loader, logger); | ||
| const { manifest } = await environment.runner.import(SERIALIZED_MANIFEST_ID); | ||
| async function createHandler(environment) { | ||
| const loader = createViteLoader(viteServer, environment); | ||
| const { default: createAstroServerApp } = await environment.runner.import(ASTRO_DEV_SERVER_APP_ID); | ||
| const controller = createController({ loader }); | ||
| const { handler } = await createAstroServerApp(controller, settings, loader, logger); | ||
| const { manifest } = await environment.runner.import(SERIALIZED_MANIFEST_ID); | ||
| return { controller, handler, loader, manifest, environment }; | ||
| } | ||
| const ssrHandler = runnableSsrEnvironment ? await createHandler(runnableSsrEnvironment) : void 0; | ||
| const prerenderHandler = runnablePrerenderEnvironment ? await createHandler(runnablePrerenderEnvironment) : void 0; | ||
| const localStorage = new AsyncLocalStorage(); | ||
@@ -62,10 +71,20 @@ function handleUnhandledRejection(rejection) { | ||
| const store = localStorage.getStore(); | ||
| if (store instanceof IncomingMessage) { | ||
| setRouteError(controller.state, store.url, error); | ||
| const handlers = []; | ||
| if (ssrHandler) handlers.push(ssrHandler); | ||
| if (prerenderHandler) handlers.push(prerenderHandler); | ||
| for (const currentHandler of handlers) { | ||
| if (store instanceof IncomingMessage) { | ||
| setRouteError(currentHandler.controller.state, store.url, error); | ||
| } | ||
| const { errorWithMetadata } = recordServerError( | ||
| currentHandler.loader, | ||
| currentHandler.manifest, | ||
| logger, | ||
| error | ||
| ); | ||
| setTimeout( | ||
| async () => currentHandler.loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)), | ||
| 200 | ||
| ); | ||
| } | ||
| const { errorWithMetadata } = recordServerError(loader, manifest, logger, error); | ||
| setTimeout( | ||
| async () => loader.webSocketSend(await getViteErrorPayload(errorWithMetadata)), | ||
| 200 | ||
| ); | ||
| } | ||
@@ -77,2 +96,8 @@ process.on("unhandledRejection", handleUnhandledRejection); | ||
| return () => { | ||
| const shouldHandlePrerenderInCore = Boolean( | ||
| viteServer[devPrerenderMiddlewareSymbol] | ||
| ); | ||
| if (!ssrHandler && !(prerenderHandler && shouldHandlePrerenderInCore)) { | ||
| return; | ||
| } | ||
| viteServer.middlewares.stack.unshift({ | ||
@@ -94,12 +119,45 @@ route: "", | ||
| }); | ||
| viteServer.middlewares.use(async function astroDevHandler(request, response) { | ||
| if (request.url === void 0 || !request.method) { | ||
| response.writeHead(500, "Incomplete request"); | ||
| response.end(); | ||
| return; | ||
| } | ||
| localStorage.run(request, () => { | ||
| handler(request, response); | ||
| if (prerenderHandler && shouldHandlePrerenderInCore) { | ||
| viteServer.middlewares.use( | ||
| async function astroDevPrerenderHandler(request, response, next) { | ||
| if (request.url === void 0 || !request.method) { | ||
| response.writeHead(500, "Incomplete request"); | ||
| response.end(); | ||
| return; | ||
| } | ||
| if (request.url.startsWith("/@") || request.url.startsWith("/__")) { | ||
| return next(); | ||
| } | ||
| if (request.url.includes("/node_modules/")) { | ||
| return next(); | ||
| } | ||
| try { | ||
| const pathname = decodeURI(new URL(request.url, "http://localhost").pathname); | ||
| const { routes } = await prerenderHandler.environment.runner.import("virtual:astro:routes"); | ||
| const routesList = { routes: routes.map((r) => r.routeData) }; | ||
| const matches = matchAllRoutes(pathname, routesList); | ||
| if (!matches.some((route) => route.prerender)) { | ||
| return next(); | ||
| } | ||
| localStorage.run(request, () => { | ||
| prerenderHandler.handler(request, response); | ||
| }); | ||
| } catch (err) { | ||
| next(err); | ||
| } | ||
| } | ||
| ); | ||
| } | ||
| if (ssrHandler) { | ||
| viteServer.middlewares.use(async function astroDevHandler(request, response) { | ||
| if (request.url === void 0 || !request.method) { | ||
| response.writeHead(500, "Incomplete request"); | ||
| response.end(); | ||
| return; | ||
| } | ||
| localStorage.run(request, () => { | ||
| ssrHandler.handler(request, response); | ||
| }); | ||
| }); | ||
| }); | ||
| } | ||
| }; | ||
@@ -106,0 +164,0 @@ } |
@@ -45,12 +45,15 @@ import { prependForwardSlash } from "@astrojs/internal-helpers/path"; | ||
| function astroDevCssPlugin({ routesList, command }) { | ||
| let ssrEnvironment = void 0; | ||
| let server; | ||
| const cssContentCache = /* @__PURE__ */ new Map(); | ||
| function getCurrentEnvironment(pluginEnv) { | ||
| return pluginEnv ?? server?.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]; | ||
| } | ||
| return [ | ||
| { | ||
| name: MODULE_DEV_CSS, | ||
| async configureServer(server) { | ||
| ssrEnvironment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]; | ||
| async configureServer(viteServer) { | ||
| server = viteServer; | ||
| }, | ||
| applyToEnvironment(env) { | ||
| return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client; | ||
| return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender; | ||
| }, | ||
@@ -85,4 +88,5 @@ resolveId: { | ||
| const componentPageId = getVirtualModulePageNameForComponent(componentPath); | ||
| await ssrEnvironment?.fetchModule(componentPageId); | ||
| const resolved = await ssrEnvironment?.pluginContainer.resolveId(componentPageId); | ||
| const env = getCurrentEnvironment(this.environment); | ||
| await env?.fetchModule(componentPageId); | ||
| const resolved = await env?.pluginContainer.resolveId(componentPageId); | ||
| if (!resolved?.id) { | ||
@@ -93,3 +97,3 @@ return { | ||
| } | ||
| const mod = ssrEnvironment?.moduleGraph.getModuleById(resolved.id); | ||
| const mod = env?.moduleGraph.getModuleById(resolved.id); | ||
| if (!mod) { | ||
@@ -129,3 +133,4 @@ return { | ||
| } | ||
| const mod = ssrEnvironment?.moduleGraph.getModuleById(id); | ||
| const env = getCurrentEnvironment(this.environment); | ||
| const mod = env?.moduleGraph.getModuleById(id); | ||
| if (mod) { | ||
@@ -140,3 +145,3 @@ cssContentCache.set(id, code); | ||
| applyToEnvironment(env) { | ||
| return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.astro; | ||
| return env.name === ASTRO_VITE_ENVIRONMENT_NAMES.ssr || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.client || env.name === ASTRO_VITE_ENVIRONMENT_NAMES.prerender; | ||
| }, | ||
@@ -143,0 +148,0 @@ resolveId: { |
@@ -80,7 +80,18 @@ import { extname } from "node:path"; | ||
| }); | ||
| let environment = server.environments[ASTRO_VITE_ENVIRONMENT_NAMES.ssr]; | ||
| const virtualMod = environment.moduleGraph.getModuleById(ASTRO_ROUTES_MODULE_ID_RESOLVED); | ||
| if (!virtualMod) return; | ||
| environment.moduleGraph.invalidateModule(virtualMod); | ||
| environment.hot.send("astro:routes-updated", {}); | ||
| const environmentsToInvalidate = []; | ||
| for (const name of [ | ||
| ASTRO_VITE_ENVIRONMENT_NAMES.ssr, | ||
| ASTRO_VITE_ENVIRONMENT_NAMES.prerender | ||
| ]) { | ||
| const environment = server.environments[name]; | ||
| if (environment) { | ||
| environmentsToInvalidate.push(environment); | ||
| } | ||
| } | ||
| for (const environment of environmentsToInvalidate) { | ||
| const virtualMod = environment.moduleGraph.getModuleById(ASTRO_ROUTES_MODULE_ID_RESOLVED); | ||
| if (!virtualMod) continue; | ||
| environment.moduleGraph.invalidateModule(virtualMod); | ||
| environment.hot.send("astro:routes-updated", {}); | ||
| } | ||
| } | ||
@@ -87,0 +98,0 @@ } |
+3
-3
| { | ||
| "name": "astro", | ||
| "version": "6.0.2", | ||
| "version": "6.0.3", | ||
| "description": "Astro is a modern site builder with web best practices, performance, and DX front-of-mind.", | ||
@@ -156,5 +156,5 @@ "type": "module", | ||
| "zod": "^4.3.6", | ||
| "@astrojs/internal-helpers": "0.8.0", | ||
| "@astrojs/markdown-remark": "7.0.0", | ||
| "@astrojs/telemetry": "3.3.0", | ||
| "@astrojs/markdown-remark": "7.0.0" | ||
| "@astrojs/internal-helpers": "0.8.0" | ||
| }, | ||
@@ -161,0 +161,0 @@ "optionalDependencies": { |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 7 instances in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
2591868
0.15%68454
0.13%