@astrojs/cloudflare 7.5.3 → 7.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,4 +1,4 @@
1
- import type { Request as CFRequest, CacheStorage, ExecutionContext } from '@cloudflare/workers-types';
1
+ import type { CacheStorage, ExecutionContext, Request as CFRequest } from '@cloudflare/workers-types';
2
2
  import type { SSRManifest } from 'astro';
3
3
  type Env = {
4
4
  ASSETS: {
@@ -1,48 +1,44 @@
1
- import { App } from "astro/app";
2
- import { getProcessEnvProxy, isNode } from "../util.js";
1
+ import { App } from 'astro/app';
2
+ import { getProcessEnvProxy, isNode } from '../util.js';
3
3
  if (!isNode) {
4
- process.env = getProcessEnvProxy();
4
+ process.env = getProcessEnvProxy();
5
5
  }
6
- function createExports(manifest) {
7
- const app = new App(manifest);
8
- const fetch = async (request, env, context) => {
9
- process.env = env;
10
- const { pathname } = new URL(request.url);
11
- if (manifest.assets.has(pathname)) {
12
- return env.ASSETS.fetch(request);
13
- }
14
- let routeData = app.match(request, { matchNotFound: true });
15
- if (routeData) {
16
- Reflect.set(
17
- request,
18
- Symbol.for("astro.clientAddress"),
19
- request.headers.get("cf-connecting-ip")
20
- );
21
- const locals = {
22
- runtime: {
23
- waitUntil: (promise) => {
24
- context.waitUntil(promise);
25
- },
26
- env,
27
- cf: request.cf,
28
- caches
6
+ export function createExports(manifest) {
7
+ const app = new App(manifest);
8
+ const fetch = async (request, env, context) => {
9
+ // TODO: remove this any cast in the future
10
+ // REF: the type cast to any is needed because the Cloudflare Env Type is not assignable to type 'ProcessEnv'
11
+ process.env = env;
12
+ const { pathname } = new URL(request.url);
13
+ // static assets fallback, in case default _routes.json is not used
14
+ if (manifest.assets.has(pathname)) {
15
+ return env.ASSETS.fetch(request);
29
16
  }
30
- };
31
- let response = await app.render(request, routeData, locals);
32
- if (app.setCookieHeaders) {
33
- for (const setCookieHeader of app.setCookieHeaders(response)) {
34
- response.headers.append("Set-Cookie", setCookieHeader);
17
+ let routeData = app.match(request, { matchNotFound: true });
18
+ if (routeData) {
19
+ Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip'));
20
+ const locals = {
21
+ runtime: {
22
+ waitUntil: (promise) => {
23
+ context.waitUntil(promise);
24
+ },
25
+ env: env,
26
+ cf: request.cf,
27
+ caches: caches,
28
+ },
29
+ };
30
+ let response = await app.render(request, routeData, locals);
31
+ if (app.setCookieHeaders) {
32
+ for (const setCookieHeader of app.setCookieHeaders(response)) {
33
+ response.headers.append('Set-Cookie', setCookieHeader);
34
+ }
35
+ }
36
+ return response;
35
37
  }
36
- }
37
- return response;
38
- }
39
- return new Response(null, {
40
- status: 404,
41
- statusText: "Not found"
42
- });
43
- };
44
- return { default: { fetch } };
38
+ return new Response(null, {
39
+ status: 404,
40
+ statusText: 'Not found',
41
+ });
42
+ };
43
+ return { default: { fetch } };
45
44
  }
46
- export {
47
- createExports
48
- };
@@ -1,4 +1,4 @@
1
- import type { Request as CFRequest, CacheStorage, EventContext } from '@cloudflare/workers-types';
1
+ import type { CacheStorage, EventContext, Request as CFRequest } from '@cloudflare/workers-types';
2
2
  import type { SSRManifest } from 'astro';
3
3
  export interface DirectoryRuntime<T extends object = object> {
4
4
  runtime: {
@@ -1,50 +1,46 @@
1
- import { App } from "astro/app";
2
- import { getProcessEnvProxy, isNode } from "../util.js";
1
+ import { App } from 'astro/app';
2
+ import { getProcessEnvProxy, isNode } from '../util.js';
3
3
  if (!isNode) {
4
- process.env = getProcessEnvProxy();
4
+ process.env = getProcessEnvProxy();
5
5
  }
6
- function createExports(manifest) {
7
- const app = new App(manifest);
8
- const onRequest = async (context) => {
9
- const request = context.request;
10
- const { env } = context;
11
- process.env = env;
12
- const { pathname } = new URL(request.url);
13
- if (manifest.assets.has(pathname)) {
14
- return env.ASSETS.fetch(request);
15
- }
16
- let routeData = app.match(request, { matchNotFound: true });
17
- if (routeData) {
18
- Reflect.set(
19
- request,
20
- Symbol.for("astro.clientAddress"),
21
- request.headers.get("cf-connecting-ip")
22
- );
23
- const locals = {
24
- runtime: {
25
- waitUntil: (promise) => {
26
- context.waitUntil(promise);
27
- },
28
- env: context.env,
29
- cf: request.cf,
30
- caches
6
+ export function createExports(manifest) {
7
+ const app = new App(manifest);
8
+ const onRequest = async (context) => {
9
+ const request = context.request;
10
+ const { env } = context;
11
+ // TODO: remove this any cast in the future
12
+ // REF: the type cast to any is needed because the Cloudflare Env Type is not assignable to type 'ProcessEnv'
13
+ process.env = env;
14
+ const { pathname } = new URL(request.url);
15
+ // static assets fallback, in case default _routes.json is not used
16
+ if (manifest.assets.has(pathname)) {
17
+ return env.ASSETS.fetch(request);
31
18
  }
32
- };
33
- let response = await app.render(request, routeData, locals);
34
- if (app.setCookieHeaders) {
35
- for (const setCookieHeader of app.setCookieHeaders(response)) {
36
- response.headers.append("Set-Cookie", setCookieHeader);
19
+ let routeData = app.match(request, { matchNotFound: true });
20
+ if (routeData) {
21
+ Reflect.set(request, Symbol.for('astro.clientAddress'), request.headers.get('cf-connecting-ip'));
22
+ const locals = {
23
+ runtime: {
24
+ waitUntil: (promise) => {
25
+ context.waitUntil(promise);
26
+ },
27
+ env: context.env,
28
+ cf: request.cf,
29
+ caches: caches,
30
+ },
31
+ };
32
+ let response = await app.render(request, routeData, locals);
33
+ if (app.setCookieHeaders) {
34
+ for (const setCookieHeader of app.setCookieHeaders(response)) {
35
+ response.headers.append('Set-Cookie', setCookieHeader);
36
+ }
37
+ }
38
+ return response;
37
39
  }
38
- }
39
- return response;
40
- }
41
- return new Response(null, {
42
- status: 404,
43
- statusText: "Not found"
44
- });
45
- };
46
- return { onRequest, manifest };
40
+ return new Response(null, {
41
+ status: 404,
42
+ statusText: 'Not found',
43
+ });
44
+ };
45
+ return { onRequest, manifest };
47
46
  }
48
- export {
49
- createExports
50
- };
@@ -1,36 +1,30 @@
1
- function getAdapter({
2
- isModeDirectory,
3
- functionPerRoute
4
- }) {
5
- const astroFeatures = {
6
- hybridOutput: "stable",
7
- staticOutput: "unsupported",
8
- serverOutput: "stable",
9
- assets: {
10
- supportKind: "stable",
11
- isSharpCompatible: false,
12
- isSquooshCompatible: false
1
+ export function getAdapter({ isModeDirectory, functionPerRoute, }) {
2
+ const astroFeatures = {
3
+ hybridOutput: 'stable',
4
+ staticOutput: 'unsupported',
5
+ serverOutput: 'stable',
6
+ assets: {
7
+ supportKind: 'stable',
8
+ isSharpCompatible: false,
9
+ isSquooshCompatible: false,
10
+ },
11
+ };
12
+ if (isModeDirectory) {
13
+ return {
14
+ name: '@astrojs/cloudflare',
15
+ serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.directory.js',
16
+ exports: ['onRequest', 'manifest'],
17
+ adapterFeatures: {
18
+ functionPerRoute,
19
+ edgeMiddleware: false,
20
+ },
21
+ supportedAstroFeatures: astroFeatures,
22
+ };
13
23
  }
14
- };
15
- if (isModeDirectory) {
16
24
  return {
17
- name: "@astrojs/cloudflare",
18
- serverEntrypoint: "@astrojs/cloudflare/entrypoints/server.directory.js",
19
- exports: ["onRequest", "manifest"],
20
- adapterFeatures: {
21
- functionPerRoute,
22
- edgeMiddleware: false
23
- },
24
- supportedAstroFeatures: astroFeatures
25
+ name: '@astrojs/cloudflare',
26
+ serverEntrypoint: '@astrojs/cloudflare/entrypoints/server.advanced.js',
27
+ exports: ['default'],
28
+ supportedAstroFeatures: astroFeatures,
25
29
  };
26
- }
27
- return {
28
- name: "@astrojs/cloudflare",
29
- serverEntrypoint: "@astrojs/cloudflare/entrypoints/server.advanced.js",
30
- exports: ["default"],
31
- supportedAstroFeatures: astroFeatures
32
- };
33
30
  }
34
- export {
35
- getAdapter
36
- };