1
+ // @ts -check
1
2
// deno-lint-ignore-file no-var prefer-const no-unused-vars no-explicit-any
2
3
import { decode as _base64Decode } from 'https://deno.land/std@0.175.0/encoding/base64.ts'
3
4
import { AsyncLocalStorage as ALSCompat } from 'https://deno.land/std@0.175.0/node/async_hooks.ts'
@@ -7,17 +8,9 @@ import { AsyncLocalStorage as ALSCompat } from 'https://deno.land/std@0.175.0/no
7
8
* This file isn't imported, but is instead inlined along with other chunks into the edge bundle.
8
9
*/
9
10
10
- declare global {
11
- var process : {
12
- env : Record < string , string >
13
- }
14
- var EdgeRuntime : string
15
- var AsyncLocalStorage : typeof ALSCompat
16
- var _ASSETS : Record < string , string >
17
- }
18
-
19
11
// Deno defines "window", but naughty libraries think this means it's a browser
20
- delete ( globalThis as Omit < typeof globalThis , 'window' > & Pick < Partial < typeof globalThis > , 'window' > ) . window
12
+ // @ts -ignore
13
+ delete globalThis . window
21
14
globalThis . process = {
22
15
env : { ...Deno . env . toObject ( ) , NEXT_RUNTIME : 'edge' , NEXT_PRIVATE_MINIMAL_MODE : '1' } ,
23
16
}
@@ -29,7 +22,8 @@ globalThis.AsyncLocalStorage = ALSCompat
29
22
30
23
// Next.js uses this extension to the Headers API implemented by Cloudflare workerd
31
24
if ( ! ( 'getAll' in Headers . prototype ) ) {
32
- ; ( Headers as any ) . prototype . getAll = function getAll ( name : string ) {
25
+ // @ts -ignore
26
+ Headers . prototype . getAll = function getAll ( name ) {
33
27
name = name . toLowerCase ( )
34
28
if ( name !== 'set-cookie' ) {
35
29
throw new Error ( 'Headers.getAll is only supported for Set-Cookie' )
@@ -39,7 +33,7 @@ if (!('getAll' in Headers.prototype)) {
39
33
}
40
34
// Next uses blob: urls to refer to local assets, so we need to intercept these
41
35
const _fetch = globalThis . fetch
42
- const fetch : typeof globalThis . fetch = async ( url , init ) => {
36
+ const fetch /* type { typeof globalThis.fetch} */ = async ( url , init ) => {
43
37
try {
44
38
if ( url instanceof URL && url . href ?. startsWith ( 'blob:' ) ) {
45
39
const key = url . href . slice ( 5 )
0 commit comments