@opennextjs/cloudflare 0.0.0-af15fd1 → 0.0.0-b997312

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.
@@ -0,0 +1,32 @@
1
+ // src/api/get-cloudflare-context.ts
2
+ import "server-only";
3
+ var cloudflareContextSymbol = Symbol.for("__cloudflare-context__");
4
+ async function getCloudflareContext() {
5
+ const global = globalThis;
6
+ const cloudflareContext = global[cloudflareContextSymbol];
7
+ if (!cloudflareContext) {
8
+ return getCloudflareContextInNextDev();
9
+ }
10
+ return cloudflareContext;
11
+ }
12
+ var cloudflareContextInNextDevSymbol = Symbol.for("__next-dev/cloudflare-context__");
13
+ async function getCloudflareContextInNextDev() {
14
+ const global = globalThis;
15
+ if (!global[cloudflareContextInNextDevSymbol]) {
16
+ const { getPlatformProxy } = await import(
17
+ /* webpackIgnore: true */
18
+ `${"__wrangler".replaceAll("_", "")}`
19
+ );
20
+ const { env, cf, ctx } = await getPlatformProxy();
21
+ global[cloudflareContextInNextDevSymbol] = {
22
+ env,
23
+ cf,
24
+ ctx
25
+ };
26
+ }
27
+ return global[cloudflareContextInNextDevSymbol];
28
+ }
29
+
30
+ export {
31
+ getCloudflareContext
32
+ };
@@ -19,8 +19,6 @@ type CloudflareContext<CfProperties extends Record<string, unknown> = IncomingRe
19
19
  /**
20
20
  * Utility to get the current Cloudflare context
21
21
  *
22
- * Throws an error if the context could not be retrieved
23
- *
24
22
  * @returns the cloudflare context
25
23
  */
26
24
  declare function getCloudflareContext<CfProperties extends Record<string, unknown> = IncomingRequestCfProperties, Context = ExecutionContext>(): Promise<CloudflareContext<CfProperties, Context>>;
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCloudflareContext
3
- } from "./chunk-LA734VUG.mjs";
3
+ } from "./chunk-VTBEIZPQ.mjs";
4
4
  export {
5
5
  getCloudflareContext
6
6
  };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  getCloudflareContext
3
- } from "./chunk-LA734VUG.mjs";
3
+ } from "./chunk-VTBEIZPQ.mjs";
4
4
  export {
5
5
  getCloudflareContext
6
6
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@opennextjs/cloudflare",
3
3
  "description": "Cloudflare builder for next apps",
4
- "version": "0.0.0-af15fd1",
4
+ "version": "0.0.0-b997312",
5
5
  "bin": "dist/cli/index.mjs",
6
6
  "main": "./dist/api/index.mjs",
7
7
  "types": "./dist/api/index.d.mts",
@@ -43,6 +43,9 @@
43
43
  "dependencies": {
44
44
  "ts-morph": "^23.0.0"
45
45
  },
46
+ "peerDependencies": {
47
+ "wrangler": "^3.78.6"
48
+ },
46
49
  "scripts": {
47
50
  "build": "tsup",
48
51
  "build:watch": "tsup --watch src",
@@ -1,14 +0,0 @@
1
- // src/api/get-cloudflare-context.ts
2
- import "server-only";
3
- var cloudflareContextSymbol = Symbol.for("__cloudflare-context__");
4
- async function getCloudflareContext() {
5
- const cloudflareContext = globalThis[cloudflareContextSymbol];
6
- if (!cloudflareContext) {
7
- throw new Error("Cloudflare context is not defined!");
8
- }
9
- return cloudflareContext;
10
- }
11
-
12
- export {
13
- getCloudflareContext
14
- };