fix(cloudflare): runtime types for Cloudflare caches (#8782)
* fix cachestorage reference in cloudflare integration * add cachestorage to serverdirectorymode * add changeset * remove global caches type * update unlucky-avocados-brake.md
This commit is contained in:
parent
9cd6a6657b
commit
75781643a2
3 changed files with 15 additions and 7 deletions
5
.changeset/unlucky-avocados-brake.md
Normal file
5
.changeset/unlucky-avocados-brake.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
'@astrojs/cloudflare': patch
|
||||||
|
---
|
||||||
|
|
||||||
|
fixes `AdvancedRuntime` & `DirectoryRuntime` types to work woth Cloudflare caches
|
|
@ -1,4 +1,8 @@
|
||||||
import type { Request as CFRequest, ExecutionContext } from '@cloudflare/workers-types';
|
import type {
|
||||||
|
Request as CFRequest,
|
||||||
|
ExecutionContext,
|
||||||
|
CacheStorage,
|
||||||
|
} from '@cloudflare/workers-types';
|
||||||
import type { SSRManifest } from 'astro';
|
import type { SSRManifest } from 'astro';
|
||||||
import { App } from 'astro/app';
|
import { App } from 'astro/app';
|
||||||
import { getProcessEnvProxy, isNode } from '../util.js';
|
import { getProcessEnvProxy, isNode } from '../util.js';
|
||||||
|
@ -16,7 +20,7 @@ export interface AdvancedRuntime<T extends object = object> {
|
||||||
waitUntil: (promise: Promise<any>) => void;
|
waitUntil: (promise: Promise<any>) => void;
|
||||||
env: Env & T;
|
env: Env & T;
|
||||||
cf: CFRequest['cf'];
|
cf: CFRequest['cf'];
|
||||||
caches: typeof caches;
|
caches: CacheStorage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +54,7 @@ export function createExports(manifest: SSRManifest) {
|
||||||
},
|
},
|
||||||
env: env,
|
env: env,
|
||||||
cf: request.cf,
|
cf: request.cf,
|
||||||
caches: caches,
|
caches: caches as unknown as CacheStorage,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import type { Request as CFRequest, EventContext } from '@cloudflare/workers-types';
|
import type { Request as CFRequest, EventContext, CacheStorage } from '@cloudflare/workers-types';
|
||||||
import type { SSRManifest } from 'astro';
|
import type { SSRManifest } from 'astro';
|
||||||
import { App } from 'astro/app';
|
import { App } from 'astro/app';
|
||||||
import { getProcessEnvProxy, isNode } from '../util.js';
|
import { getProcessEnvProxy, isNode } from '../util.js';
|
||||||
|
@ -6,13 +6,12 @@ import { getProcessEnvProxy, isNode } from '../util.js';
|
||||||
if (!isNode) {
|
if (!isNode) {
|
||||||
process.env = getProcessEnvProxy();
|
process.env = getProcessEnvProxy();
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface DirectoryRuntime<T extends object = object> {
|
export interface DirectoryRuntime<T extends object = object> {
|
||||||
runtime: {
|
runtime: {
|
||||||
waitUntil: (promise: Promise<any>) => void;
|
waitUntil: (promise: Promise<any>) => void;
|
||||||
env: EventContext<unknown, string, unknown>['env'] & T;
|
env: EventContext<unknown, string, unknown>['env'] & T;
|
||||||
cf: CFRequest['cf'];
|
cf: CFRequest['cf'];
|
||||||
caches: typeof caches;
|
caches: CacheStorage;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,7 +47,7 @@ export function createExports(manifest: SSRManifest) {
|
||||||
},
|
},
|
||||||
env: context.env,
|
env: context.env,
|
||||||
cf: request.cf,
|
cf: request.cf,
|
||||||
caches: caches,
|
caches: caches as unknown as CacheStorage,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue